Boost logo

Boost :

From: Chris Weed (chrisweed_at_[hidden])
Date: 2006-07-24 17:36:49


I have a set of types, that are either native types or array types
that have a typedef called value_type, which is a native type. I can
get this value_type using the following metafunction:

template<typename T>
struct get_value_type
{
  typedef typename T::value_type type;
};

I was using mpl if_ incorrectly so that instead of creating an object
of "value_type", I was creating an object of "get_value_type" like the
following;

struct MyType { typedef int value_type };

typedef MyType T;
typedef mpl::if_<mpl::not<is_pod<T> >,get_value_type<T>,T>::type my_type;

my_type t;

It can be difficult to understand the difference between if_ and
eval_if. If I derive get_value_type from nonconstructible, this would
not have compiled.

Chris

On 7/24/06, Gennaro Prota <gennaro_prota_at_[hidden]> wrote:
> On Mon, 24 Jul 2006 15:54:33 -0400, "Chris Weed" <chrisweed_at_[hidden]>
> wrote:
>
> >Recently I was burned by a traits class that was getting constructed.
>
> Out of curiosity, what problem did you have?
>
> --
> [ Gennaro Prota, C++ developer for hire ]
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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