‘typeid’ versus ‘typeof’ in C++

C++ language has no such thing as typeof. You must be looking at some compiler-specific extension. If you are talking about GCC’s typeof, then a similar feature is present in C++11 through the keyword decltype. Again, C++ has no such typeof keyword. typeid is a C++ language operator which returns type identification information at run … Read more

recursive variadic template to print out the contents of a parameter pack

There’s actually a very elegant way to end the recursion: template <typename Last> std::string type_name () { return std::string(typeid(Last).name()); } template <typename First, typename Second, typename …Rest> std::string type_name () { return std::string(typeid(First).name()) + ” ” + type_name<Second, Rest…>(); } I initially tried template <typename Last> and template <typename First, typename …Rest> but that was … Read more