Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)");
- }
Advertisement
Add Comment
Please, Sign In to add comment