Skip to content

Commit 4851608

Browse files
authored
implement P3557, get_completion_signatures with constexpr exceptions (NVIDIA#1745)
1 parent 71d22ca commit 4851608

File tree

129 files changed

+1878
-1564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1878
-1564
lines changed

.clang-format

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ RequiresClausePosition: OwnLine
121121
IndentRequiresClause: true
122122
SeparateDefinitionBlocks: Leave
123123
ShortNamespaceLines: 0
124-
SortIncludes: Never
124+
SortIncludes:
125+
Enabled: true
126+
IgnoreCase: false
125127
SortUsingDeclarations: false
126128
SpaceAfterCStyleCast: true
127129
SpaceAfterLogicalNot: false

examples/hello_coro.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// Pull in the reference implementation of P2300:
1919
#include <stdexec/execution.hpp>
2020

21-
#if !STDEXEC_STD_NO_COROUTINES() && !STDEXEC_NVHPC()
21+
#if !STDEXEC_NO_STD_COROUTINES() && !STDEXEC_NVHPC()
2222
# include <exec/task.hpp>
2323

2424
using namespace stdexec;

examples/server_theme/let_value.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
// Use a thread pool
5353
#include "exec/static_thread_pool.hpp"
5454

55-
#if !STDEXEC_STD_NO_EXCEPTIONS()
55+
#if !STDEXEC_NO_STD_EXCEPTIONS()
5656
namespace ex = stdexec;
5757

5858
struct http_request {
@@ -159,4 +159,4 @@ int main() {
159159
std::cout << "This example requires C++ exceptions to be enabled.\n";
160160
return 0;
161161
}
162-
#endif // !STDEXEC_STD_NO_EXCEPTIONS()
162+
#endif // !STDEXEC_NO_STD_EXCEPTIONS()

include/asioexec/as_default_on.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
#pragma once
2020

21-
#include <type_traits>
22-
#include <utility>
2321
#include <asioexec/asio_config.hpp>
2422
#include <asioexec/executor_with_default.hpp>
23+
#include <type_traits>
24+
#include <utility>
2525

2626
namespace asioexec {
2727

include/asioexec/completion_token.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
#pragma once
2020

21+
#include <asioexec/as_default_on.hpp>
22+
#include <asioexec/asio_config.hpp>
2123
#include <concepts>
2224
#include <exception>
2325
#include <functional>
2426
#include <mutex>
2527
#include <optional>
28+
#include <stdexec/execution.hpp>
2629
#include <tuple>
2730
#include <type_traits>
2831
#include <utility>
2932
#include <version>
30-
#include <asioexec/as_default_on.hpp>
31-
#include <asioexec/asio_config.hpp>
32-
#include <stdexec/execution.hpp>
3333

3434
namespace asioexec {
3535

@@ -527,7 +527,7 @@ namespace ASIOEXEC_ASIO_NAMESPACE {
527527
template <typename... Signatures>
528528
struct async_result<::asioexec::completion_token_t, Signatures...> {
529529
template <typename Initiation, typename... Args>
530-
requires (std::is_constructible_v<std::decay_t<Args>, Args> && ...)
530+
requires(std::is_constructible_v<std::decay_t<Args>, Args> && ...)
531531
static constexpr auto
532532
initiate(Initiation&& i, const ::asioexec::completion_token_t&, Args&&... args) {
533533
return ::asioexec::detail::completion_token::sender<

include/asioexec/use_sender.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
#pragma once
2020

21+
#include <asioexec/as_default_on.hpp>
22+
#include <asioexec/asio_config.hpp>
23+
#include <asioexec/completion_token.hpp>
2124
#include <concepts>
2225
#include <exception>
26+
#include <stdexec/execution.hpp>
2327
#include <system_error>
2428
#include <type_traits>
2529
#include <utility>
26-
#include <asioexec/as_default_on.hpp>
27-
#include <asioexec/asio_config.hpp>
28-
#include <asioexec/completion_token.hpp>
29-
#include <stdexec/execution.hpp>
3030

3131
namespace asioexec {
3232

include/exec/__detail/__basic_sequence.hpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
*/
1717
#pragma once
1818

19+
#include "../../stdexec/__detail/__basic_sender.hpp"
1920
#include "../../stdexec/__detail/__config.hpp"
2021
#include "../../stdexec/__detail/__meta.hpp"
21-
#include "../../stdexec/__detail/__basic_sender.hpp"
2222

2323
#include "../sequence_senders.hpp"
2424

@@ -63,24 +63,17 @@ namespace exec {
6363
return _Self::__tag().get_env(*this);
6464
}
6565

66-
template <stdexec::__decays_to<__seqexpr> _Self, class... _Env>
67-
STDEXEC_EXPLICIT_THIS_BEGIN(
68-
auto get_completion_signatures)(this _Self&& __self, _Env&&... __env)
69-
-> decltype(__self.__tag().get_completion_signatures(
70-
static_cast<_Self&&>(__self),
71-
static_cast<_Env&&>(__env)...)) {
72-
return {};
66+
template <stdexec::__decays_to_derived_from<__seqexpr> _Self, class... _Env>
67+
static consteval auto get_completion_signatures() {
68+
return __tag_t::template get_completion_signatures<_Self, _Env...>();
7369
}
74-
STDEXEC_EXPLICIT_THIS_END(get_completion_signatures)
7570

76-
template <stdexec::__decays_to<__seqexpr> _Self, class... _Env>
77-
static auto get_item_types(_Self&& __self, _Env&&... __env)
78-
-> decltype(__self.__tag()
79-
.get_item_types(static_cast<_Self&&>(__self), static_cast<_Env&&>(__env)...)) {
80-
return {};
71+
template <stdexec::__decays_to_derived_from<__seqexpr> _Self, class... _Env>
72+
static consteval auto get_item_types() {
73+
return __tag_t::template get_item_types<_Self, _Env...>();
8174
}
8275

83-
template <stdexec::__decays_to<__seqexpr> _Self, stdexec::receiver _Receiver>
76+
template <stdexec::__decays_to_derived_from<__seqexpr> _Self, stdexec::receiver _Receiver>
8477
static auto subscribe(_Self&& __self, _Receiver&& __rcvr) noexcept(noexcept(
8578
__self.__tag().subscribe(static_cast<_Self&&>(__self), static_cast<_Receiver&&>(__rcvr))))
8679
-> decltype(__self.__tag()

include/exec/__detail/__system_context_replaceability_api.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
#include "../../stdexec/__detail/__execution_fwd.hpp"
2121

22-
#include <cstdint>
2322
#include <cstddef>
23+
#include <cstdint>
2424
#include <exception>
25-
#include <optional>
2625
#include <memory>
26+
#include <optional>
2727
#include <span>
2828

2929
struct __uuid {

include/exec/any_sender_of.hpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
#pragma once
1717

18-
#include "../stdexec/execution.hpp"
1918
#include "../stdexec/__detail/__any_receiver_ref.hpp"
19+
#include "../stdexec/execution.hpp"
2020

2121
#include "sequence_senders.hpp"
2222

@@ -245,7 +245,8 @@ namespace exec {
245245
class _Allocator,
246246
bool _Copyable = false,
247247
std::size_t _InlineSize = 3 * sizeof(void*),
248-
std::size_t _Alignment = alignof(std::max_align_t)>
248+
std::size_t _Alignment = alignof(std::max_align_t)
249+
>
249250
struct __storage {
250251
class __t;
251252
};
@@ -254,7 +255,8 @@ namespace exec {
254255
class _Vtable,
255256
class _Allocator,
256257
std::size_t _InlineSize = 3 * sizeof(void*),
257-
std::size_t _Alignment = alignof(std::max_align_t)>
258+
std::size_t _Alignment = alignof(std::max_align_t)
259+
>
258260
struct __immovable_storage {
259261
class __t : __immovable {
260262
static constexpr std::size_t __buffer_size = std::max(_InlineSize, sizeof(void*));
@@ -374,7 +376,8 @@ namespace exec {
374376
class _Allocator,
375377
bool _Copyable,
376378
std::size_t _InlineSize,
377-
std::size_t _Alignment>
379+
std::size_t _Alignment
380+
>
378381
class __storage<_Vtable, _Allocator, _Copyable, _InlineSize, _Alignment>::__t
379382
: __if_c<_Copyable, __, __move_only> {
380383
static_assert(
@@ -393,7 +396,8 @@ namespace exec {
393396
using __vtable_t = __if_c<
394397
_Copyable,
395398
__storage_vtable<_Vtable, __with_delete, __with_move, __with_copy>,
396-
__storage_vtable<_Vtable, __with_delete, __with_move>>;
399+
__storage_vtable<_Vtable, __with_delete, __with_move>
400+
>;
397401

398402
template <class _Tp>
399403
static constexpr auto __get_vtable_of_type() noexcept -> const __vtable_t* {
@@ -404,7 +408,8 @@ namespace exec {
404408
_Vtable,
405409
__with_delete,
406410
__with_move,
407-
__with_copy>;
411+
__with_copy
412+
>;
408413
} else {
409414
return &__storage_vtbl<__t, __decay_t<_Tp>, _Vtable, __with_delete, __with_move>;
410415
}
@@ -581,7 +586,8 @@ namespace exec {
581586
class _VTable = __empty_vtable,
582587
class _Allocator = std::allocator<std::byte>,
583588
std::size_t _InlineSize = 3 * sizeof(void*),
584-
std::size_t _Alignment = alignof(std::max_align_t)>
589+
std::size_t _Alignment = alignof(std::max_align_t)
590+
>
585591
using __immovable_storage_t =
586592
__t<__immovable_storage<_VTable, _Allocator, _InlineSize, _Alignment>>;
587593

@@ -591,7 +597,8 @@ namespace exec {
591597
template <
592598
class _VTable,
593599
std::size_t _InlineSize = 3 * sizeof(void*),
594-
class _Allocator = std::allocator<std::byte>>
600+
class _Allocator = std::allocator<std::byte>
601+
>
595602
using __copyable_storage_t = __t<__storage<_VTable, _Allocator, true, _InlineSize>>;
596603

597604
template <class _Tag, class... _As>
@@ -755,7 +762,8 @@ namespace exec {
755762
using _FilteredQueries =
756763
__minvoke<__mremove_if<__q<__is_never_stop_token_query_t>>, _Queries...>;
757764
using __vtable_t = stdexec::__t<
758-
__mapply<__mbind_front_q<__vtable, completion_signatures<_Sigs...>>, _FilteredQueries>>;
765+
__mapply<__mbind_front_q<__vtable, completion_signatures<_Sigs...>>, _FilteredQueries>
766+
>;
759767

760768
struct __env_t {
761769
const __vtable_t* __vtable_;
@@ -1052,7 +1060,8 @@ namespace exec {
10521060

10531061
template <receiver_of<_Sigs> _Rcvr>
10541062
auto connect(_Rcvr __rcvr) && -> stdexec::__t<
1055-
__operation<stdexec::__id<_Rcvr>, __with_inplace_stop_token>> {
1063+
__operation<stdexec::__id<_Rcvr>, __with_inplace_stop_token>
1064+
> {
10561065
return {static_cast<__t&&>(*this), static_cast<_Rcvr&&>(__rcvr)};
10571066
}
10581067

@@ -1207,7 +1216,8 @@ namespace exec {
12071216
template <auto... _SenderQueries>
12081217
class any_sender {
12091218
using __sender_base = stdexec::__t<
1210-
__any::__sender<_Completions, queries<_SenderQueries...>, queries<_ReceiverQueries...>>>;
1219+
__any::__sender<_Completions, queries<_SenderQueries...>, queries<_ReceiverQueries...>>
1220+
>;
12111221
__sender_base __sender_;
12121222

12131223
public:
@@ -1243,7 +1253,8 @@ namespace exec {
12431253
// Add the required set_value_t() completions to the schedule-sender.
12441254
using __schedule_completions = stdexec::__concat_completion_signatures<
12451255
_Completions,
1246-
stdexec::completion_signatures<stdexec::set_value_t()>>;
1256+
stdexec::completion_signatures<stdexec::set_value_t()>
1257+
>;
12471258
using __schedule_receiver = any_receiver_ref<__schedule_completions, _ReceiverQueries...>;
12481259

12491260
template <class _BaseSender>
@@ -1291,8 +1302,10 @@ namespace exec {
12911302
using __schedule_sender_base_t = stdexec::__minvoke<
12921303
stdexec::__mremove_if<
12931304
__any::__ret_equals_to<stdexec::get_completion_scheduler_t<stdexec::set_value_t>>,
1294-
stdexec::__q<__any_sender_t>>,
1295-
decltype(_SenderQueries)...>;
1305+
stdexec::__q<__any_sender_t>
1306+
>,
1307+
decltype(_SenderQueries)...
1308+
>;
12961309

12971310
using __schedule_sender_t = __schedule_sender<__schedule_sender_base_t>;
12981311

include/exec/async_scope.hpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616
#pragma once
1717

18-
#include "../stdexec/execution.hpp"
19-
#include "../stdexec/stop_token.hpp"
2018
#include "../stdexec/__detail/__intrusive_queue.hpp"
2119
#include "../stdexec/__detail/__optional.hpp"
20+
#include "../stdexec/execution.hpp"
21+
#include "../stdexec/stop_token.hpp"
2222
#include "env.hpp"
2323

2424
#include "../stdexec/__detail/__atomic.hpp"
@@ -383,15 +383,17 @@ namespace exec {
383383
}
384384

385385
template <class _Receiver2>
386-
explicit __t(
387-
_Receiver2&& __rcvr, std::unique_ptr<__future_state<_Sender, _Env>> __state)
388-
: __subscription{{},
389-
[](__subscription* __self) noexcept -> void {
386+
explicit __t(_Receiver2&& __rcvr, std::unique_ptr<__future_state<_Sender, _Env>> __state)
387+
: __subscription{
388+
{},
389+
[](__subscription* __self) noexcept -> void {
390390
static_cast<__t*>(__self)->__complete_();
391-
}}
391+
}}
392392
, __rcvr_(static_cast<_Receiver2&&>(__rcvr))
393393
, __state_(std::move(__state))
394-
, __forward_consumer_(std::in_place, get_stop_token(get_env(__rcvr_)),
394+
, __forward_consumer_(
395+
std::in_place,
396+
get_stop_token(get_env(__rcvr_)),
395397
__forward_stopped{&__state_->__stop_source_}) {
396398
}
397399

@@ -485,7 +487,10 @@ namespace exec {
485487
template <class _Completions, class _Env>
486488
struct __future_state_base {
487489
__future_state_base(_Env __env, const __impl* __scope)
488-
: __forward_scope_{std::in_place, __scope->__stop_source_.get_token(), __forward_stopped{&__stop_source_}}
490+
: __forward_scope_{
491+
std::in_place,
492+
__scope->__stop_source_.get_token(),
493+
__forward_stopped{&__stop_source_}}
489494
, __env_(make_env(
490495
static_cast<_Env&&>(__env),
491496
stdexec::prop{get_stop_token, __scope->__stop_source_.get_token()})) {
@@ -757,9 +762,8 @@ namespace exec {
757762

758763
struct __t : __spawn_op_base<_EnvId> {
759764
__t(connect_t, _Sender&& __sndr, _Env __env, const __impl* __scope)
760-
: __spawn_op_base<
761-
_EnvId
762-
>{__env::__join(
765+
: __spawn_op_base<_EnvId>{
766+
__env::__join(
763767
static_cast<_Env&&>(__env),
764768
__spawn_env_{__scope->__stop_source_.get_token()}),
765769
[](__spawn_op_base<_EnvId>* __op) { delete static_cast<__t*>(__op); }}

0 commit comments

Comments
 (0)