Cookie
Cookie

Reputation: 12662

Get template parameter from boost::ptr_vector

From boost::ptr_vector<T> I am trying to get T, but boost::ptr_vector<T>::value_type seems to be T*. How can I get T?

Looking at the doc, I see:

typedef  T*                                           value_type;
typedef  T&                                           reference;
typedef  const T&                                     const_reference;

None of which help...

Upvotes: 0

Views: 53

Answers (2)

Aurelius
Aurelius

Reputation: 11329

Since you're using Boost, you can use boost::remove_pointer to get the pointed-to type.

boost::remove_pointer<boost::ptr_vector<T>::value_type>::type

will evaluate to T.

If you can use C++11 features, you could use std::remove_pointer in the same manner as Boost's version.

Upvotes: 2

Paul
Paul

Reputation: 13238

If you can use C++11, std::remove_pointer on value_type should do the job.

Upvotes: 2

Related Questions