Document Number |
P1328R0 |
Date |
2018-10-28 |
Project |
Programming Language C++ |
Audience |
Evolution Working Group |
Summary |
This paper proposes making |
Table of Contents
Summary
typeid
(with the exception of its application on polymorphic glvalues, a
restriction that P1327 proposes to lift) is
currently allowed in constant expressions, but the resulting std::type_info
object is unusable as it has no constexpr
member functions.
This paper proposes std::type_info::operator==
and operator!=
be made
constexpr
, enabling practical, rather than theoretical, use of typeid
in constant expressions.
Proposed Changes
-
namespace std { class type_info { public: virtual ~type_info(); constexpr bool operator==(const type_info& rhs) const noexcept; constexpr bool operator!=(const type_info& rhs) const noexcept; size_t hash_code() const noexcept; const char* name() const noexcept; type_info(const type_info& rhs) = delete; // cannot be copied type_info& operator=(const type_info& rhs) = delete; // cannot be copied }; }
constexpr bool operator==(const type_info& rhs) const noexcept;
constexpr bool operator!=(const type_info& rhs) const noexcept;
-- end