Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-07-06 14:33:12


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Rob Stewart

> > Way. We are not talking about the functions, we're talking about
> > their types. In other words, the traits do not inspect individual
> > values of int (*)(int) -- they inspect the type int(*)(int)
> itself. I
> > don't think there's any problem with calling int(*)(int) a
> nonmember
> > function pointer type.
>
> If you're thinking about whether the type is that of a static
> member function, then you won't be thinking that you should
> use "nonmember."

Just to be pedantic, the types of member functions are regular function types
also. Furthermore, you *can* have cv-qualified function types, such as 'int
(int) const'. The differences are that you cannot declare a non-member function
with a cv-qualified function type and that the types of pointers to actual
functions differ based on whether they are (non-static) member functions. E.g.

typedef void func();

func f;

struct x {
        func f;
};

&f -> void (*)()
&x::f -> void (x::*)()

Likewise:

template<class> struct remove_pointer_to_member;

template<class R, class C> struct remove_pointer_to_member {
    typedef R type;
};

remove_pointer_to_member< void (x::*)() >::type -> void ()

Basically, the argument between member and non-member doesn't apply to function
types. If, OTOH, you're really talking about pointers to functions and pointers
to member functions, then a type difference becomes evident and there is a
significant distinction. In that case, the types are "pointers to function"
(which is the type classification of a pointer to static member function) and
"pointer to member function" (which is the type classification of a pointer to
non-static member function). I think it is a misuse of terminology to say "the
type of a function" and really mean "the type of a pointer to function."

Regards,
Paul Mensonides


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