c++/10649: is_pointer<T> reports pointer to member function is not a pointer

Giovanni Bajo giovannibajo@libero.it
Wed May 7 23:52:00 GMT 2003


Robert Schwartz <robertallanschwartz@yahoo.com> wrote:

> is_pointer<int foo::*>::value (i.e. pointer to member variable) evaluates
> to true.
> If I remove the * from "int foo::*", then I get "int foo::".
> I know this isn't a valid C++ type, but a pointer to a member variable is
> still a pointer, no?
>
> If I remove the * from "int (foo::*)(void)", then I get "int
(foo::)(void)".
> I know this isn't a valid C++ type, but a pointer to a member function is
> still a pointer, no?


I'm not arguing about what is a pointer and what is not. I'm saying that a
compiler can't instantiate your template with "T = int foo::" because "int
foo::" is not a type, like you are stating yourself. This does not mean that
a pointer to a member function or a member variable is not a pointer. It
simply means that your way to detect what is a pointer and what is not a
pointer is wrong. You can check the Type Trait library within Boost, they
have metafunctions to check for every thing you can think of about types,
and they work on every compiler out there (most of them can work even
without partial specialization). It will give you an idea about how to
implement such constructs.

Giovanni Bajo



More information about the Gcc-bugs mailing list