
AMDG jean-louis.a.leroy@fortis.com wrote:
I need to compare is_const<T> with true_ or false_. I don't find an easy way to do it. I have tried:
void foo(mpl::true_) { cout << "true" << endl; } void foo(mpl::false_) { cout << "false" << endl; }
int _tmain(int argc, _TCHAR* argv[]) { foo(is_same< mpl::true_, is_pointer<void*>() >()); foo(is_same< mpl::true_, is_pointer<void*>::type() >()); foo(is_convertible< is_pointer<void*>(), mpl::true_ >()); foo(is_base_of< mpl::true_, is_pointer<void*>() >()); return 0; }
(in case you wonder why I don't simply pass is_pointer to foo(), here's why: I have a function object that is called twice with a bool_ template argument; the first time it handles all non-pointer types and in a second pass it handles the pointer types; in fact I'm trying to implement the equivalent of b1 == b2, where b1 and b2 are bools).
I'm quite sure that I follow. Do you mean that you have a template like this: template<bool B> void f(mpl::bool_<B>);
I understand that is_pointer<T> derives either from true_type or false_type. Thus it's normal that is_same fails. But what of the others?
Remove the () after is_pointer<>. is_pointer<void*>() is a function type. In Christ, Steven Watanabe