Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2003-01-12 16:08:07


----- Original Message -----
From: "David Abrahams" <dave_at_[hidden]>

> > template<class> struct test;
> >
> > template<class R, class C> struct test<R C::*> {
> > typedef R type;
> > };
> >
> > struct X { };
> >
> > test< void (X::*)(int) >::type // what type is this?
> >
> > Is it a function type, or is it a "member function type"?
>
> If it's legal, it's a function type. Interestingly, MWCW seems to
> think it's:
>
> void (void *const , const void *const , int)

Weird.

> But none of the other compilers seem to think it's a function type. I
> know that when Howard mentioned that he thought it was natural to get
> a function type by stripping the "pointer to member" part from a
> pointer to member function in some committee discussion, it generated
> a little bit of surprisee at least.

Yeah, what about "void (X::*)(int) const"? It seems like it is of type
"member function type" since, for obvious reasons, a freestanding function
cannot be cv-qualified.

> I can't tell what EDG thinks it is, but whatever it is, it's not a
> function type.

EDG treats it like a special type of function type. For instance, trying to
apply const to it yields a "applying const to a function-type" error. Also,
'typeid(R).name()' yields "void (int)" which is, of course, a function type.
However, 'is_same<R, void (int)>::value' yields false. On the other hand,
'typeid(R).name()', when 'R' is from a const-qualified
pointer-to-member-function, yields "void (int) const", which is obviously
*not* a function type. The best I can make out is that EDG treats it as a
"member function type".

> GCC thinks it's illegal.

Which part? Just the existence of 'R' at all? If that is the case, than
GCC is wrong. It looks like we have a hole in the type system here. The
specialization: R C::* should catch all pointers-to-members, including
pointers-to-member-functions. Therefore, the type 'R' exists, but has no
name, and is nothing that you could specify by yourself.

Paul Mensonides


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