After reading C++ compile-time string hashing with Boost.MPL, and considering a problem I have, the following came to my mind.
I have the base class:
template<class Command>
class Base {
typedef Command CommandType;
}
It is supposed to be a utility base class for the Commands classes, so they don't need to typedef and declare some members on their own, they would simply inherit from Base with the types they refer to. So they can be used like this:
class CommandInstantiatorA : public Base<CommandA>
{
public:
static std::string GetID() { return "CommandInstantiatorA "; }
}
However, there is this other method (GetID) which I couldnt "templatize" which returns an unique ID throught the application. I would like to be able to hash the type passed to the class Base, so the other classes would only need to specify the type. Something like this:
template <class Base>
class Base {
typedef boost::hash_value(TO_STRING(Base)) ID; //should also be read as: typedef boost::hash_value("CommandA") ID;
...
}
Is there such a macro (TO_STRING) that would yield the result "CommandA" in the last example. Is there anything in Boost.MPL that can do this?