Consider a class template that implements a container that includes the ability to select a place to store.
template<class T>
class Container {
public:
enum StorageOption {A,B};
Container(StorageOption opt_): option(opt_) {}
private:
StorageOption option;
};
Here StorageOptionwas selected as a member, since it is used only in the class.
Now, to create an instance of the class, I will need to repeat the template parameter, for example:
{
Container<int> c( Container<int>::A );
}
Is there a way to avoid repeating the parameter and at the same time have StorageOptiona member, or is there a better way to implement the option?
source
share