N
neelagain
Hi,
I want to write a template _something_ like this:
class baseStoreType {};
template <class storeType> class Store {
storeType storeData;
};
For template parameter storeType, there should be two options :
storeType = baseStoreType * or any other class derived from
baseStoreType
- OR -
storeType = smart_ptr<baseStoreType * or any other class derived from
baseStoreType>
where smart_ptr can be std::auto_ptr, boost::shared_ptr and so on.
The simple solution could be
typedef Store<baseStoreType *> BaseStore;
but that means template parameter storeType can be of any type when my
requirements are different (to allow only types with/without smart
pointers derived from baseStoreType).
Is there a better way?
Thanks in advance,
- Neel.
I want to write a template _something_ like this:
class baseStoreType {};
template <class storeType> class Store {
storeType storeData;
};
For template parameter storeType, there should be two options :
storeType = baseStoreType * or any other class derived from
baseStoreType
- OR -
storeType = smart_ptr<baseStoreType * or any other class derived from
baseStoreType>
where smart_ptr can be std::auto_ptr, boost::shared_ptr and so on.
The simple solution could be
typedef Store<baseStoreType *> BaseStore;
but that means template parameter storeType can be of any type when my
requirements are different (to allow only types with/without smart
pointers derived from baseStoreType).
Is there a better way?
Thanks in advance,
- Neel.