Skip to content

Commit 12978b3

Browse files
[libc++] P2602R2 Poison Pills are Too Toxic (#74534)
Implements [P2602R2 Poison Pills are Too Toxic](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2602r2.html) as a DR in C++20 mode.
1 parent 8e69052 commit 12978b3

File tree

16 files changed

+147
-35
lines changed

16 files changed

+147
-35
lines changed

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"`P2396R1 <https://wg21.link/P2396R1>`__","LWG", "Concurrency TS 2 fixes ", "November 2022","","","|concurrency TS|"
101101
"`P2505R5 <https://wg21.link/P2505R5>`__","LWG", "Monadic Functions for ``std::expected``", "November 2022","|Complete|","17.0",""
102102
"`P2539R4 <https://wg21.link/P2539R4>`__","LWG", "Should the output of ``std::print`` to a terminal be synchronized with the underlying stream?", "November 2022","|Complete|","18.0","|format|"
103-
"`P2602R2 <https://wg21.link/P2602R2>`__","LWG", "Poison Pills are Too Toxic", "November 2022","","","|ranges|"
103+
"`P2602R2 <https://wg21.link/P2602R2>`__","LWG", "Poison Pills are Too Toxic", "November 2022","|Complete|","19.0","|ranges|"
104104
"`P2708R1 <https://wg21.link/P2708R1>`__","LWG", "No Further Fundamentals TSes", "November 2022","|Nothing to do|","",""
105105
"","","","","","",""
106106
"`P0290R4 <https://wg21.link/P0290R4>`__","LWG", "``apply()`` for ``synchronized_value<T>``","February 2023","","","|concurrency TS|"

libcxx/include/__compare/partial_order.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828

2929
// [cmp.alg]
3030
namespace __partial_order {
31+
void partial_order() = delete;
32+
3133
struct __fn {
3234
// NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here
3335
template <class _Tp, class _Up>

libcxx/include/__compare/strong_order.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3737

3838
// [cmp.alg]
3939
namespace __strong_order {
40+
void strong_order() = delete;
41+
4042
struct __fn {
4143
// NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here
4244
template <class _Tp, class _Up>

libcxx/include/__compare/weak_order.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3030

3131
// [cmp.alg]
3232
namespace __weak_order {
33+
void weak_order() = delete;
34+
3335
struct __fn {
3436
// NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here
3537
template <class _Tp, class _Up>

libcxx/include/__iterator/iter_move.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3535
namespace ranges {
3636
namespace __iter_move {
3737

38-
void iter_move();
38+
void iter_move() = delete;
3939

4040
template <class _Tp>
4141
concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {

libcxx/include/__ranges/access.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && require
4545
{ _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator;
4646
};
4747

48-
void begin(auto&) = delete;
49-
void begin(const auto&) = delete;
48+
void begin() = delete;
5049

5150
template <class _Tp>
5251
concept __unqualified_begin =
@@ -109,8 +108,7 @@ concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(
109108
{ _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
110109
};
111110

112-
void end(auto&) = delete;
113-
void end(const auto&) = delete;
111+
void end() = delete;
114112

115113
template <class _Tp>
116114
concept __unqualified_end =

libcxx/include/__ranges/rbegin.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ concept __member_rbegin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requir
4040
{ _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
4141
};
4242

43-
void rbegin(auto&) = delete;
44-
void rbegin(const auto&) = delete;
43+
void rbegin() = delete;
4544

4645
template <class _Tp>
4746
concept __unqualified_rbegin =

libcxx/include/__ranges/rend.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ concept __member_rend = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires
4242
{ _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
4343
};
4444

45-
void rend(auto&) = delete;
46-
void rend(const auto&) = delete;
45+
void rend() = delete;
4746

4847
template <class _Tp>
4948
concept __unqualified_rend =

libcxx/include/__ranges/size.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ inline constexpr bool disable_sized_range = false;
4141

4242
namespace ranges {
4343
namespace __size {
44-
void size(auto&) = delete;
45-
void size(const auto&) = delete;
44+
void size() = delete;
4645

4746
template <class _Tp>
4847
concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;

libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.swap/iter_swap.pass.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ static_assert( std::is_invocable_v<IterSwapT&&, HasIterSwap&, HasIterSwap&>);
4747
static_assert( std::is_invocable_v<IterSwapT&&, HasIterSwap&, int&>);
4848
static_assert(!std::is_invocable_v<IterSwapT&&, int&, HasIterSwap&>);
4949

50+
struct StructWithNotMoreSpecializedIterSwap {
51+
friend void iter_swap(auto&, auto&);
52+
};
53+
54+
static_assert(
55+
!std::is_invocable_v<IterSwapT, StructWithNotMoreSpecializedIterSwap&, StructWithNotMoreSpecializedIterSwap&>);
56+
5057
struct NodiscardIterSwap {
5158
[[nodiscard]] friend int iter_swap(NodiscardIterSwap&, NodiscardIterSwap&) { return 0; }
5259
};

0 commit comments

Comments
 (0)