Skip to content

Commit d292972

Browse files
authored
[libc++] Implements P2517R1. (#77239)
As pointed out by @Zingam the paper was implemented in libc++ as an extension. This patch does the bookkeeping. The inital release version is based on historical release dates. Completes: - Add a conditional noexcept specification to std::apply
1 parent 064e73c commit d292972

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

libcxx/docs/ReleaseNotes/18.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Implemented Papers
5959
- P2821R5 - span.at()
6060
- P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
6161
- P1759R6 - Native handles and file streams
62+
- P2517R1 - Add a conditional ``noexcept`` specification to ``std::apply``
6263

6364

6465
Improvements and New Features

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"`P2502R2 <https://wg21.link/P2502R2>`__","LWG","``std::generator``: Synchronous Coroutine Generator for Ranges","July 2022","","","|ranges|"
8484
"`P2508R1 <https://wg21.link/P2508R1>`__","LWG","Exposing ``std::basic-format-string``","July 2022","|Complete|","15.0"
8585
"`P2513R4 <https://wg21.link/P2513R4>`__","LWG","``char8_t`` Compatibility and Portability Fixes","July 2022","",""
86-
"`P2517R1 <https://wg21.link/P2517R1>`__","LWG","Add a conditional ``noexcept`` specification to ``std::apply``","July 2022","",""
86+
"`P2517R1 <https://wg21.link/P2517R1>`__","LWG","Add a conditional ``noexcept`` specification to ``std::apply``","July 2022","|Complete|","3.9"
8787
"`P2520R0 <https://wg21.link/P2520R0>`__","LWG","``move_iterator`` should be a random access iterator","July 2022","|Complete| [#note-P2520R0]_","17.0","|ranges|"
8888
"`P2540R1 <https://wg21.link/P2540R1>`__","LWG","Empty Product for certain Views","July 2022","","","|ranges|"
8989
"`P2549R1 <https://wg21.link/P2549R1>`__","LWG","``std::unexpected`` should have ``error()`` as member accessor","July 2022","|Complete|","16.0"

libcxx/include/tuple

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // cons
141141
142142
// [tuple.apply], calling a function with a tuple of arguments:
143143
template <class F, class Tuple>
144-
constexpr decltype(auto) apply(F&& f, Tuple&& t); // C++17
144+
constexpr decltype(auto) apply(F&& f, Tuple&& t) noexcept(see below); // C++17 noexcept since C++23
145145
template <class T, class Tuple>
146146
constexpr T make_from_tuple(Tuple&& t); // C++17
147147

libcxx/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// <tuple>
1212

13-
// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&)
13+
// template <class F, class T> constexpr decltype(auto) apply(F &&, T &&) noexcept(see below) // noexcept since C++23
1414

1515
// Test with different ref/ptr/cv qualified argument types.
1616

@@ -192,15 +192,23 @@ void test_noexcept()
192192
// test that the functions noexcept-ness is propagated
193193
using Tup = std::tuple<int, const char*, long>;
194194
Tup t;
195+
#if TEST_STD_VER >= 23
196+
ASSERT_NOEXCEPT(std::apply(nec, t));
197+
#else
195198
LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, t));
199+
#endif
196200
ASSERT_NOT_NOEXCEPT(std::apply(tc, t));
197201
}
198202
{
199203
// test that the noexcept-ness of the argument conversions is checked.
200204
using Tup = std::tuple<NothrowMoveable, int>;
201205
Tup t;
202206
ASSERT_NOT_NOEXCEPT(std::apply(nec, t));
207+
#if TEST_STD_VER >= 23
208+
ASSERT_NOEXCEPT(std::apply(nec, std::move(t)));
209+
#else
203210
LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, std::move(t)));
211+
#endif
204212
}
205213
}
206214

0 commit comments

Comments
 (0)