
2009/5/6 Ryan McConnehey <mccorywork@gmail.com>
Roman Perepelitsa wrote:
template<typename S, *int N*> struct ParameterValue { ParameterValue(S value_) : value(value_) {} S value };
typedef ParameterValue<std::string, *0*> ConfigName; typedef ParameterValue<std::string, *1*> PathName;
Roman Perepelitsa.
Is is possible to have the number be generated automatically so that it doesn't need to be defined by the user?
I don't think so. If you want to protect yourself from accidentally using the same number with different types, you can try the following: template<typename S, *typename Tag*> struct ParameterValue { ParameterValue(S value_) : value(value_) {} S value }; *struct ConfigNameTag {};* typedef ParameterValue<std::string, *ConfigNameTag*> ConfigName; *struct PathNameTag {};* typedef ParameterValue<std::string, *PathNameTag*> PathName; Roman Perepelitsa.