Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-12 16:38:06


>From: "Paul Mensonides" <pmenso57_at_[hidden]>

> From: "David Abrahams" <dave_at_[hidden]>
>
> > >> Here's an interesting turn-of-the-tables: I was experimenting with
> > >> using SFINAE to disable conversion operators, and I discovered that
> > >> almost every compiler except vc6/7 rejects this code:
> > >>
> > >> template <class T> struct voidify { typedef void type; };
> > >> template <class T> struct Y {};
> > >> struct X
> > >> {
> > >> template <class T>
> > >> operator Y<T> (typename voidify<T>::type) const { return
Y<T>(); }
> > >> };
> > >
> > > Is this even legal? I.e. for a user-defined conversion operator to
have
> any
> > > arguments at all?
> >
> > Look twice; the argument is void.
>
> I know, but I don't think you can derive a 'void' parameter list that way.

<snip>

> In other words, the "void" parameter list is fundamentally different than
> "type void".

It appears this is right. 8.3.5/2 says: "[...] If the
parameter-declaration-clause is empty, the function takes no arguments. 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)."

So it seems only "void" can be used, not any type expression that evaluates
to void.

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk