Boost logo

Boost Users :

Subject: Re: [Boost-users] Comparing is_pointer with true_
From: jean-louis.a.leroy_at_[hidden]
Date: 2009-01-19 03:38:19


> 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>);

Nearly. It's more like this:

template<class WritePointers, ...>
struct WriteAttributes {
  template<class Attribute>
  void operator ()(Attribute a) const
  {
    typedef ... attribute_type;
    write(is_convertible<is_pointer<attribute_type>, WritePointers>(), ...);
  }
  template<...>
  void write(mpl::false_, ...); // non-pointer pass
  template<...>
  void write(mpl::true_, ...); // pointer pass
  // ...
};

(dots are just for brevity) which I use like this:

  mirror::for_each< meta_class<Class>::attributes >(WriteAttributes<false_, ...>(ar, obj));
  mirror::for_each< meta_class<Class>::attributes >(WriteAttributes<true_, ...>(ar, obj));

> > 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.

Indeed. Thanks a lot :-)

Regards,
Jean-Louis

= = = = = = = = = = = = = = = = = = = = = = = = =
Fortis disclaimer :
http://www.fortis.be/legal/disclaimer.htm

Privacy policy related to banking activities of Fortis:
http://www.fortis.be/legal/privacy_policy.htm
= = = = = = = = = = = = = = = = = = = = = = = = =


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