If a pointer to an user defined type is passed as template argument to a template class, is it possible to get the class type of the argument?
template <class T> struct UserType {
typedef T value_type;
...
};
int main () {
typedef std::vector<UserType<double>*> vecType
vecType vec;
vecType::value_type::value_type m; //how to get the double here?
return 0;
}
Use traits:
template <typename> struct ptr_traits {};
template <typename T> struct ptr_traits<T*>
{ typedef T value_type; };
ptr_traits<vecType::value_type>::value_type m;
Use boost::remove_pointer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With