remove_pointer and pointers to members?

Folks, I'm trying to decide how to fix this bug report: https://svn.boost.org/trac/boost/ticket/2011 Basically what should: remove_pointer<int (foo::*)>::type be? Should it produce an int, or have no effect? TR1 explicitly says that it has no effect, so I guess I vote to stick with that behaviour. In which case, anyone object to a remove_member_pointer trait that transforms: int (foo::*) --> int int (foo::*)(double) --> int (double) etc. It's also tempting to add a "member_object" trait at the same time that transforms: int (foo::*) --> foo int (foo::*)(double) --> foo thoughts? Thanks, John.

AMDG John Maddock wrote:
Folks, I'm trying to decide how to fix this bug report: https://svn.boost.org/trac/boost/ticket/2011
Basically what should: remove_pointer<int (foo::*)>::type be? Should it produce an int, or have no effect? TR1 explicitly says that it has no effect, so I guess I vote to stick with that behaviour.
Agreed.
In which case, anyone object to a remove_member_pointer trait that transforms:
Nope. I've needed this in the past and wondered why it wasn't present.
It's also tempting to add a "member_object" trait at the same time that transforms:
Good idea. In Christ, Steven Watanabe

While we're speaking of traits, could it be possible to have a remove_all_pointers which remove all the pointer qualifier of a type (much like remove_all_extent do for arrays) ? Other point, shouldn't the return type of all meta-function be mpl::true_ and mpl::false_ ? It is somehow cumbersome to have two set of boolean meta-data. Thanks for reading

joel falcou wrote:
While we're speaking of traits, could it be possible to have a remove_all_pointers which remove all the pointer qualifier of a type (much like remove_all_extent do for arrays) ?
Probably :-) Anyone else have a need for this?
Other point, shouldn't the return type of all meta-function be mpl::true_ and mpl::false_ ? It is somehow cumbersome to have two set of boolean meta-data.
type_traits uses integral_constant<bool,val> for true/false results which in turn inherits from mpl::bool_<val> so the two should be completely compatible with each other. Note that integral_constant is part of the TR1 and the next std, where as MPL is not, so type_traits won't be changing in this respect. John.

type_traits uses integral_constant<bool,val> for true/false results which in turn inherits from mpl::bool_<val> so the two should be completely compatible with each other. Note that integral_constant is part of the TR1 and the next std, where as MPL is not, so type_traits won't be changing in this respect.
OK, so it's maybe me. I used a lot of type_traits and MPL meta-function as generator for static boolean that serves as templae overload selector like : template<class T, class EnableIf = is_integral<T>::type> struct foo; template<class T> struct foo<T,false_type> {}; and I found that having to manage both true_/false_ and true_type/false_type in various overload a bit hard, especially if a tempalte has two set of EnableIf,one using traits one using MPL. Is going with usign the ::value a better idea, (aka making EnableIf a bool parameter ?) Thanks anyway for your welcomed insight

On Mon, Jul 28, 2008 at 8:35 AM, John Maddock <john@johnmaddock.co.uk> wrote:
In which case, anyone object to a remove_member_pointer trait that transforms:
int (foo::*) --> int int (foo::*)(double) --> int (double)
etc.
It's also tempting to add a "member_object" trait at the same time that transforms:
int (foo::*) --> foo int (foo::*)(double) --> foo
thoughts?
I think I've had a need for both of these before, and IIRC in both cases I used the FunctionTypes library to get the answer. Metafunctions that provide the answers directly would be nice, but I'm not sure whether they would fit better in TypeTraits or FunctionTypes. Stjepan

Stjepan Rajko wrote:
I think I've had a need for both of these before, and IIRC in both cases I used the FunctionTypes library to get the answer.
Hmmm, I don't see anything in the function traits docs to obtain the type of an object from a pointer to member [function] ? John.

On Tue, Jul 29, 2008 at 5:06 AM, John Maddock <john@johnmaddock.co.uk> wrote:
Stjepan Rajko wrote:
I think I've had a need for both of these before, and IIRC in both cases I used the FunctionTypes library to get the answer.
Hmmm, I don't see anything in the function traits docs to obtain the type of an object from a pointer to member [function] ?
parameter_types (under type decomposition) returns the (transformed) type of object as the second element of it's answer for member function pointers. Stjepan

Bruno Lalande wrote:
Hi,
It's also tempting to add a "member_object" trait at the same time that transforms:
int (foo::*) --> foo int (foo::*)(double) --> foo
Good idea, just a little naming consideration: member_to_object or object_from_member would sound more explicit to me...
Ah, yes the old naming problem ;-) Don't forget the trait will likely always be used with the ::type suffix, so member_object<T>::type doesn't look so bad to me, but anyone else have preferences for these or other names? Thanks, John.
participants (5)
-
Bruno Lalande
-
joel falcou
-
John Maddock
-
Steven Watanabe
-
Stjepan Rajko