Maybe sometimes, we need to test whether 2 types are the same, Well, there are several ways. You can refer to the following:
1. Use TypeID, perhaps this is the most common method:
Template
Struct Same_Type
{
PUBLIC:
Operator bool ()
{
Return TypeId (t ()) == TypeId (u ());
}
}
2, use template to transit:
Template
Struct Same_Type
{
Private:
Template
Struct in
{enum {value = false};
Template <>
Struct in
{enum {value = true};
PUBLIC:
Enum {value = in :: value};
}
3, use the Typelist inside the Loki library:
Template
Struct Same_Type
{
PUBLIC:
Operator bool ()
{
Return Loki :: IndexOf == 0;
}
}
嗬嗬, of course, there is also something else to share together :)