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 2006-01-12 18:46

Hmm...in that case, can anyone provide a macro-template wrapper to simulate a function similar to typeid() to accept types as a parameter?

Example:
#define myFunc(type) myHiddenFunc<type>()

but the above doesn't work like typeid() of course...
because typeid() can evaluate a type during runtime.

Example:
class A{}; class B:A{};
...
B b;
A* pA = &b;
typeid(*pA); // This will evaluate type B
myFunc(*pA); // This will evaluate type A

Any ideas?

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