سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

You can store a pointer to a constant std::type_info object.

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. The type_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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top