muse1987
July 17th, 2008, 11:53 PM
Hi
I'm gonna implement a dynamic type-cast mechanism. I need to give unique ID to all classes, and I think hash value calculated from the name of class would be appropriate.
What I'd like to do is something like this:
template <char const* const psz>
struct _hash_
{
enum {
value = *psz
? (_hash_<psz+1>::value << 2) | *psz
: 0
};
};
.........
enum {
_classid = _hash_<"cMyClass">::value
};
It produces compile errors. I can imagine the reason, (I'm afraid this is fairly stupid idea :S) but I'd like to know if there's any way around.
Thanks in advance
I'm gonna implement a dynamic type-cast mechanism. I need to give unique ID to all classes, and I think hash value calculated from the name of class would be appropriate.
What I'd like to do is something like this:
template <char const* const psz>
struct _hash_
{
enum {
value = *psz
? (_hash_<psz+1>::value << 2) | *psz
: 0
};
};
.........
enum {
_classid = _hash_<"cMyClass">::value
};
It produces compile errors. I can imagine the reason, (I'm afraid this is fairly stupid idea :S) but I'd like to know if there's any way around.
Thanks in advance