Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ typeid()

Name: Anonymous 2006-01-11 12:59

Does anyone know how typeid() is implemented in C++???
I mean, how do I make a function like typeid() where I can pass the TYPE as a paramter.

Example:
int main()
{
    typeid(int);//<-- works of course
    f(int);//<-- how to do something like this
           //        without using macros or templates
}

Name: Anonymous 2010-01-27 15:34

<<64 DONT DO THAT it breaks my SFINAE based metaprogramming reusable libraries depending on member method pointer overload resolution precedence differences between builtin and user defined types

what OP needs is clearly:

1: get a list of all used types (for example: A,B,C,D,...)
2:
/*returns the type, as string*/ template<T*> std::string typeID(T* buio){return dynamic_cast<A*>(buio)?"A":(dynamic_cast<B*>(buio)?"B":(dynamic_cast<C*>(buio)?"C":(dynamic_cast<D*>(buio)?"D":(dynamic_cast<E*>(buio)?"E":(/*more of this, also dont forget additional FV-izeation for production code*/)))));}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List