Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2007-04-18 04:57:52

Stjepan Rajko wrote:
> I am wondering if there is a construct in boost which, given a type T,
> returns the underlying "storable" type - say if T is int & the
> "storable_type" should be int. I'm not sure if the word "storable" is
> the best word...
> The scenario I am facing is making a function call that takes a
> parameter of type T, where I need to prepare the parameter before
> calling (specifically, deserializing it from an archive). Hence, as
> far as I can tell, I need to declare a variable of the underlying
> storable type, and get the right value inside it.
> So far, I've been using:
> template<typename T>
> struct storable : public boost::remove_const<typename
> boost::remove_reference<T>::type > {};
> but I'm not sure if that cuts it in all situations. In any case, I
> figured the right thing might be in Boost already and I just haven't
> found it.

No we don't have that one, well there had to be one :-)

Your code will only work for class types right? If that's an acceptable
limitation then it will do what you want, or did you mean:

template<typename T>
struct storable
  typedef typename boost::remove_const<typename
     boost::remove_reference<T>::type > type;


Which would work for just about everything except function types (may need
to be degraded to pointer-to-function), and abstract types.

HTH, John.

Boost list run by bdawes at, gregod at, cpdaniel at, john at