Topic: Defect in N2135/20.5.14.2.5: Return clause mentions undefined "type()


Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Sat, 3 Feb 2007 09:43:29 CST
Raw View
Hello,

20.5.14.2.5 p. 4 of [func.wrap.func.targ] says:

"Returns: If type() == typeid(T), a pointer to the stored function
target; otherwise a null pointer."

1) There exists neither a type, a typedef "type", nor member function
"type()" in class template function
nor in the global or std namespace.
2) Assuming that "type" should have been "target_type()", this
description would lead to false
results, if T = cv void due to returns clause 20.5.14.2.5 p. 1.

Proposed resolution:

"Returns: If target_type() == typeid(T) && typeid(T) != typeid(void),
a pointer to the stored function
target; otherwise a null pointer."

Greetings from Bremen,

Daniel Kr   gler


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Sun, 4 Feb 2007 00:44:17 CST
Raw View
On 3 Feb., 19:07, Pete Becker <p...@versatilecoding.com> wrote:
> Daniel Kr   gler wrote:
> > Proposed resolution:
>
> > "Returns: If target_type() == typeid(T) && typeid(T) != typeid(void),
> > a pointer to the stored function
> > target; otherwise a null pointer."
>
> Agreed. It's editorial, so I'll fix it.

Just after sending my contribution, I had to reconsider the 2nd
part of my assertion, which leads to the proposed addition
"&& typeid(T) != typeid(void)". One could argue that its requires
section, which says

"T is a function object type that is Callable ([20.5.14.2]) for
parameter
types T1, T2, ..., TN and return type R."

does exclude the need to take the void case into account. Formally
this violation would lead to undefined behaviour according to
17.4.3.8, right? So the question arises, whether we want U.B. here, or
not.
Personally I see no need for that, so in this case the requires
section
could be removed here. What do you think?

Greetings from Bremen,

Daniel





---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]