Skip to content

Commit

Permalink
P1328R1 constexpr type_info::operator==() (microsoft#2793)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored and fsb4000 committed Aug 13, 2022
1 parent 09e93c4 commit 35525d1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
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
3 changes: 0 additions & 3 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.deprecated.fail.cp
std/language.support/support.limits/support.limits.general/tuple.version.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/utility.version.pass.cpp FAIL

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


# *** MISSING COMPILER FEATURES ***
# Nothing here! :-)
Expand Down
3 changes: 0 additions & 3 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ utilities\meta\meta.unary\meta.unary.prop\is_literal_type.deprecated.fail.cpp
language.support\support.limits\support.limits.general\tuple.version.pass.cpp
language.support\support.limits\support.limits.general\utility.version.pass.cpp

# P1328R1 constexpr type_info::operator==()
language.support\support.limits\support.limits.general\typeinfo.version.pass.cpp


# *** MISSING COMPILER FEATURES ***
# Nothing here! :-)
Expand Down
19 changes: 17 additions & 2 deletions tests/std/tests/P2273R3_constexpr_unique_ptr/test.compile.pass.cpp
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

0 comments on commit 35525d1

Please sign in to comment.