Skip to content

Commit 35525d1

Browse files
StephanTLavavejfsb4000
authored andcommitted
P1328R1 constexpr type_info::operator==() (microsoft#2793)
1 parent 09e93c4 commit 35525d1

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

stl/inc/yvals_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
// P1132R7 out_ptr(), inout_ptr()
296296
// P1147R1 Printing volatile Pointers
297297
// P1272R4 byteswap()
298+
// P1328R1 constexpr type_info::operator==()
298299
// P1413R3 Deprecate aligned_storage And aligned_union
299300
// P1425R4 Iterator Pair Constructors For stack And queue
300301
// P1659R3 ranges::starts_with, ranges::ends_with
@@ -1456,6 +1457,7 @@
14561457

14571458
#define __cpp_lib_associative_heterogeneous_erasure 202110L
14581459
#define __cpp_lib_byteswap 202110L
1460+
#define __cpp_lib_constexpr_typeinfo 202106L
14591461

14601462
#ifdef __cpp_lib_concepts
14611463
#define __cpp_lib_expected 202202L

tests/libcxx/expected_results.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.deprecated.fail.cp
234234
std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp FAIL
235235
std/language.support/support.limits/support.limits.general/utility.version.pass.cpp FAIL
236236

237-
# P1328R1 constexpr type_info::operator==()
238-
std/language.support/support.limits/support.limits.general/typeinfo.version.pass.cpp FAIL
239-
240237

241238
# *** MISSING COMPILER FEATURES ***
242239
# Nothing here! :-)

tests/libcxx/skipped_tests.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ utilities\meta\meta.unary\meta.unary.prop\is_literal_type.deprecated.fail.cpp
234234
language.support\support.limits\support.limits.general\tuple.version.pass.cpp
235235
language.support\support.limits\support.limits.general\utility.version.pass.cpp
236236

237-
# P1328R1 constexpr type_info::operator==()
238-
language.support\support.limits\support.limits.general\typeinfo.version.pass.cpp
239-
240237

241238
# *** MISSING COMPILER FEATURES ***
242239
# Nothing here! :-)

tests/std/tests/P2273R3_constexpr_unique_ptr/test.compile.pass.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <cassert>
55
#include <memory>
6+
#include <typeinfo>
67
#include <utility>
78

89
using namespace std;
@@ -13,7 +14,7 @@ struct Dummy {
1314
}
1415
};
1516

16-
constexpr bool test() {
17+
constexpr bool test_P2273R3_constexpr_unique_ptr() {
1718
// [memory.syn]
1819
{
1920
auto p1 = make_unique<int>(42);
@@ -126,6 +127,20 @@ constexpr bool test() {
126127
return true;
127128
}
128129

129-
static_assert(test());
130+
static_assert(test_P2273R3_constexpr_unique_ptr());
131+
132+
// Also test P1328R1 constexpr type_info::operator==()
133+
constexpr bool test_P1328R1_constexpr_type_info_equality() {
134+
assert(typeid(int) == typeid(int));
135+
assert(typeid(int) != typeid(double));
136+
137+
assert(typeid(int) == typeid(int&)); // N4910 [expr.typeid]/5
138+
assert(typeid(int) == typeid(const int&)); // N4910 [expr.typeid]/5
139+
assert(typeid(int) == typeid(const int)); // N4910 [expr.typeid]/6
140+
141+
return true;
142+
}
143+
144+
static_assert(test_P1328R1_constexpr_type_info_equality());
130145

131146
int main() {} // COMPILE-ONLY

tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,20 @@ STATIC_ASSERT(__cpp_lib_constexpr_tuple == 201811L);
592592
#endif
593593
#endif
594594

595+
#if _HAS_CXX23
596+
#ifndef __cpp_lib_constexpr_typeinfo
597+
#error __cpp_lib_constexpr_typeinfo is not defined
598+
#elif __cpp_lib_constexpr_typeinfo != 202106L
599+
#error __cpp_lib_constexpr_typeinfo is not 202106L
600+
#else
601+
STATIC_ASSERT(__cpp_lib_constexpr_typeinfo == 202106L);
602+
#endif
603+
#else
604+
#ifdef __cpp_lib_constexpr_typeinfo
605+
#error __cpp_lib_constexpr_typeinfo is defined
606+
#endif
607+
#endif
608+
595609
#if _HAS_CXX20
596610
#ifndef __cpp_lib_constexpr_utility
597611
#error __cpp_lib_constexpr_utility is not defined

0 commit comments

Comments
 (0)