Boost logo

Boost Users :

Subject: Re: [Boost-users] Comparing is_pointer with true_
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-01-16 11:44:01


AMDG

jean-louis.a.leroy_at_[hidden] 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net