
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.98 KB | hits: 10 | expires: Never
typeid(T).name() alternative in c 11?
template<typename T>
class Vector {
void foo(int i) {
cout << __PRETTY_FUNCTION__ << endl;
}
};
void Vector<double>::foo(int)
template<class T> struct meta {
static const std::string& get_name() {return T::class_name;}
};
class MyClass {
public:
static const std::string class_name("MyClass");
};
template<> struct meta<int> {
static const std::string class_name("int");
static const std::string& get_name() {return class_name;}
};
#define specialize_meta(name) template<>struct meta<name>{static const std::string class_name(#name); static const std::string& get_name() {return class_name;} };
specialize_meta(double);
int main() {
std::cout << meta<int>::get_name();
}
void foo(int) {} //function in question
template<class T, T& a> struct metafunc; //dont define generic.
template<decltype(foo), &foo> struct metafunc { //specialization
static const std::string func_name("void foo(int)");
}