James Kanze
12/9/2008 2:18:00 PM
On Dec 9, 11:38 am, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
> red floyd wrote:
[...]
> > Kai-Uwe, can you tell me what's worng with this one? Is it
> > the same issue, even when I explicitly specify void?
> > template <typename R, typename TT>
> > void func_wrapper( R ( *pfunc )( TT ) )
> > {
> > }
> > void f( )
> > {
> > }
> > int main( )
> > {
> > func_wrapper<void,void>( &f ); // can't
> > }
> Yes, it's the same.
> The standard has a rather vague provison in [8.5.3/2]
> ...The parameter list (void) is equivalent to the empty parameter list.
> Except for this special case, void shall not be a parameter type (though
> types derived from void, such as void*, can). ...
Most importantly, in this case, void is not a type; it's just a
keyword with a special meaning. Thus, something like:
typedef void toto ;
void f( toto ) ;
is not legal.
> but it also has something that undoubtedly applies: a
> provision for when type deduction fails. In [14.8.2/2] it
> says:
> ... Type deduction may fail for the following reasons:
> - Attempting to create a function type in which a parameter has a
> type of void.
Exactly. Because a parameter cannot have the type void.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34