Reputation: 35485
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?
Upvotes: 15
Views: 2870
Reputation: 9156
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.
Upvotes: 11
Reputation: 818
From MSDN and IBM online documentation:
The
type_info
class describes type information generated within the program by the compiler. Objects of this class effectively store a pointer to a name for the type. Thetype_info
class also stores an encoded value suitable for comparing two types for equality or collating order. The encoding rules and collating sequence for types are unspecified and may differ between programs.
Upvotes: 0
Reputation: 56956
You can store a pointer to a constant std::type_info
object.
Upvotes: 6