Does this already exist?

N

Noah Roberts

I needed this functionality and couldn't find it. Does anyone know if
it already exists somewhere? If so I would rather use the existing
method instead of my own...


template < typename T >
struct dereference_type { typedef T type; };

template < typename T >
struct dereference_type< T* > { typedef T type; };

template < typename T >
struct dereference_type< boost::scoped_ptr< T > > { typedef T type;
};

template < typename T >
struct dereference_type< boost::shared_ptr< T > > { typedef T type;
};

template < typename T >
struct dereference_type< boost::weak_ptr< T > > { typedef T type; };
 
A

amparikh

Noah said:
I needed this functionality and couldn't find it. Does anyone know if
it already exists somewhere? If so I would rather use the existing
method instead of my own...


template < typename T >
struct dereference_type { typedef T type; };

template < typename T >
struct dereference_type< T* > { typedef T type; };

The above two are pretty generic practice I know sor sure but probably
not present in any generic header file. I have been using them in my
own code for a while.
I am not sure if it is present in Boost because I dont use it much.
 
N

Noah Roberts

The above two are pretty generic practice I know sor sure but probably
not present in any generic header file. I have been using them in my
own code for a while.
I am not sure if it is present in Boost because I dont use it much.

Yeah, I guess I should have clarified. Looking for it in std or
boost...more likely boost as I need it to work with the boost ptr
types. On the other hand, if it exists in std it wouldn't be hard to
override for boost ptr types.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top