Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P1328R1 constexpr type_info::operator==() #2793

Merged
merged 2 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
// P1132R7 out_ptr(), inout_ptr()
// P1147R1 Printing volatile Pointers
// P1272R4 byteswap()
// P1328R1 constexpr type_info::operator==()
// P1413R3 Deprecate aligned_storage And aligned_union
// P1425R4 Iterator Pair Constructors For stack And queue
// P1659R3 ranges::starts_with, ranges::ends_with
Expand Down Expand Up @@ -1456,6 +1457,7 @@

#define __cpp_lib_associative_heterogeneous_erasure 202110L
#define __cpp_lib_byteswap 202110L
#define __cpp_lib_constexpr_typeinfo 202106L

#ifdef __cpp_lib_concepts
#define __cpp_lib_expected 202202L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cassert>
#include <memory>
#include <typeinfo>
#include <utility>

using namespace std;
Expand All @@ -13,7 +14,7 @@ struct Dummy {
}
};

constexpr bool test() {
constexpr bool test_P2273R3_constexpr_unique_ptr() {
// [memory.syn]
{
auto p1 = make_unique<int>(42);
Expand Down Expand Up @@ -126,6 +127,20 @@ constexpr bool test() {
return true;
}

static_assert(test());
static_assert(test_P2273R3_constexpr_unique_ptr());

// Also test P1328R1 constexpr type_info::operator==()
constexpr bool test_P1328R1_constexpr_type_info_equality() {
assert(typeid(int) == typeid(int));
assert(typeid(int) != typeid(double));

assert(typeid(int) == typeid(int&)); // N4910 [expr.typeid]/5
assert(typeid(int) == typeid(const int&)); // N4910 [expr.typeid]/5
assert(typeid(int) == typeid(const int)); // N4910 [expr.typeid]/6

return true;
}

static_assert(test_P1328R1_constexpr_type_info_equality());

int main() {} // COMPILE-ONLY
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,20 @@ STATIC_ASSERT(__cpp_lib_constexpr_tuple == 201811L);
#endif
#endif

#if _HAS_CXX23
#ifndef __cpp_lib_constexpr_typeinfo
#error __cpp_lib_constexpr_typeinfo is not defined
#elif __cpp_lib_constexpr_typeinfo != 202106L
#error __cpp_lib_constexpr_typeinfo is not 202106L
#else
STATIC_ASSERT(__cpp_lib_constexpr_typeinfo == 202106L);
#endif
#else
#ifdef __cpp_lib_constexpr_typeinfo
#error __cpp_lib_constexpr_typeinfo is defined
#endif
#endif

#if _HAS_CXX20
#ifndef __cpp_lib_constexpr_utility
#error __cpp_lib_constexpr_utility is not defined
Expand Down