Search code examples
c++stdtypeidtypeinfo

Why is std::type_info noncopyable? Am I allowed to store it somewhere?


The std::type_info class is non-copyable. This makes it hard to store it in an object for later use. What should I do?


Solution

  • There is a much better solution in C++11. A new copyable wrapper called std::type_index. You need to include header "typeindex" to use it.