[libcxx] Put std::monostate in <utility> (#128373)

Fixes: #127874
This commit is contained in:
Amr Hesham 2025-03-25 18:31:57 +01:00 committed by GitHub
parent 25938389c0
commit 357306572d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 86 additions and 1 deletions

View File

@ -44,6 +44,7 @@ Implemented Papers
- P2255R2: A type trait to detect reference binding to temporary (implemented the type traits only) (`Github <https://github.com/llvm/llvm-project/issues/105180>`__)
- P2562R1: ``constexpr`` Stable Sorting (`Github <https://github.com/llvm/llvm-project/issues/105360>`__)
- P1222R4: A Standard ``flat_set`` is partially implemented and ``flat_set`` is provided (`Github <https://github.com/llvm/llvm-project/issues/105193>`__)
- P0472R3: Put std::monostate in <utility> (`Github <https://github.com/llvm/llvm-project/issues/127874>`__)
Improvements and New Features
-----------------------------

View File

@ -102,7 +102,7 @@
"`P3475R2 <https://wg21.link/P3475R2>`__","Defang and deprecate ``memory_order::consume``","2025-02 (Hagenberg)","","",""
"`P2786R13 <https://wg21.link/P2786R13>`__","Trivial Relocatability For C++26","2025-02 (Hagenberg)","","",""
"`P3137R3 <https://wg21.link/P3137R3>`__","``views::to_input``","2025-02 (Hagenberg)","","",""
"`P0472R3 <https://wg21.link/P0472R3>`__","Put ``std::monostate`` in ``<utility>``","2025-02 (Hagenberg)","","",""
"`P0472R3 <https://wg21.link/P0472R3>`__","Put ``std::monostate`` in ``<utility>``","2025-02 (Hagenberg)","|Complete|","21",""
"`P3349R1 <https://wg21.link/P3349R1>`__","Converting contiguous iterators to pointers","2025-02 (Hagenberg)","","",""
"`P3372R3 <https://wg21.link/P3372R3>`__","constexpr containers and adaptors","2025-02 (Hagenberg)","","",""
"`P3378R2 <https://wg21.link/P3378R2>`__","constexpr exception types","2025-02 (Hagenberg)","","",""

1 Paper # Paper Name Meeting Status First released version Notes
102 `P3475R2 <https://wg21.link/P3475R2>`__ Defang and deprecate ``memory_order::consume`` 2025-02 (Hagenberg)
103 `P2786R13 <https://wg21.link/P2786R13>`__ Trivial Relocatability For C++26 2025-02 (Hagenberg)
104 `P3137R3 <https://wg21.link/P3137R3>`__ ``views::to_input`` 2025-02 (Hagenberg)
105 `P0472R3 <https://wg21.link/P0472R3>`__ Put ``std::monostate`` in ``<utility>`` 2025-02 (Hagenberg) |Complete| 21
106 `P3349R1 <https://wg21.link/P3349R1>`__ Converting contiguous iterators to pointers 2025-02 (Hagenberg)
107 `P3372R3 <https://wg21.link/P3372R3>`__ constexpr containers and adaptors 2025-02 (Hagenberg)
108 `P3378R2 <https://wg21.link/P3378R2>`__ constexpr exception types 2025-02 (Hagenberg)

View File

@ -279,6 +279,10 @@ template <class T>
# include <__utility/unreachable.h>
# endif
# if _LIBCPP_STD_VER >= 26
# include <__variant/monostate.h>
# endif
# include <version>
// standard-mandated includes

View File

@ -301,6 +301,7 @@ experimental/type_traits type_traits
experimental/type_traits version
experimental/utility compare
experimental/utility cstdint
experimental/utility cstring
experimental/utility initializer_list
experimental/utility limits
experimental/utility utility
@ -1127,6 +1128,7 @@ unordered_set tuple
unordered_set version
utility compare
utility cstdint
utility cstring
utility initializer_list
utility limits
utility version

1 algorithm cctype
301 experimental/type_traits version
302 experimental/utility compare
303 experimental/utility cstdint
304 experimental/utility cstring
305 experimental/utility initializer_list
306 experimental/utility limits
307 experimental/utility utility
1128 unordered_set version
1129 utility compare
1130 utility cstdint
1131 utility cstring
1132 utility initializer_list
1133 utility limits
1134 utility version

View File

@ -0,0 +1,47 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// REQUIRES: std-at-least-c++26
// <utility>
// constexpr bool operator<(monostate, monostate) noexcept { return false; }
// constexpr bool operator>(monostate, monostate) noexcept { return false; }
// constexpr bool operator<=(monostate, monostate) noexcept { return true; }
// constexpr bool operator>=(monostate, monostate) noexcept { return true; }
// constexpr bool operator==(monostate, monostate) noexcept { return true; }
// constexpr bool operator!=(monostate, monostate) noexcept { return false; }
// constexpr strong_ordering operator<=>(monostate, monostate) noexcept { return strong_ordering::equal; } // since C++20
#include <cassert>
#include <utility>
#include "test_comparisons.h"
#include "test_macros.h"
constexpr bool test() {
using M = std::monostate;
constexpr M m1{};
constexpr M m2{};
assert(testComparisons(m1, m2, /*isEqual*/ true, /*isLess*/ false));
AssertComparisonsAreNoexcept<M>();
#if TEST_STD_VER > 17
assert(testOrder(m1, m2, std::strong_ordering::equal));
AssertOrderAreNoexcept<M>();
#endif // TEST_STD_VER > 17
return true;
}
int main(int, char**) {
test();
static_assert(test());
return 0;
}

View File

@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// REQUIRES: std-at-least-c++26
// <utility>
// struct monostate {};
#include <type_traits>
#include <utility>
#include "test_macros.h"
int main(int, char**) {
using M = std::monostate;
static_assert(std::is_trivially_default_constructible<M>::value, "");
static_assert(std::is_trivially_copy_constructible<M>::value, "");
static_assert(std::is_trivially_copy_assignable<M>::value, "");
static_assert(std::is_trivially_destructible<M>::value, "");
constexpr M m{};
((void)m);
return 0;
}