Skip to content

Commit 0837897

Browse files
committed
tidy the basic-sender implementation
1 parent 2200f73 commit 0837897

1 file changed

Lines changed: 6 additions & 55 deletions

File tree

include/stdexec/__detail/__basic_sender.hpp

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ namespace stdexec {
8888
__callable<__impl_of<_Sexpr>, __copy_cvref_fn<_Sexpr>, __connect_fn<_Sexpr, _Receiver>>
8989
&& __mvalid<__state_type_t, tag_of_t<_Sexpr>, _Sexpr, _Receiver>;
9090

91-
// // Note: This is UB. UBSAN allows it for now.
92-
// template <class _Parent, class _Child>
93-
// _Parent* __parent_from_child(_Child* __child, _Child _Parent::*__mbr_ptr) noexcept {
94-
// alignas(_Parent) char __buf[sizeof(_Parent)];
95-
// _Parent* __parent = (_Parent*) &__buf;
96-
// const std::ptrdiff_t __offset = (char*) &(__parent->*__mbr_ptr) - __buf;
97-
// return (_Parent*) (static_cast<char*>(__child) - __offset);
98-
// }
99-
10091
inline constexpr auto __get_attrs = //
10192
[](__ignore, const auto&... __child) noexcept -> decltype(auto) {
10293
if constexpr (sizeof...(__child) == 1) {
@@ -168,14 +159,6 @@ namespace stdexec {
168159
// this receiver.
169160
__parent_op_t* __op_;
170161

171-
// template <class _ChildSexpr, class _ChildReceiver>
172-
// static __t __from_op_state(__op_state<_ChildSexpr, _ChildReceiver>* __child) noexcept {
173-
// using __parent_op_t = __op_state<_Sexpr, _Receiver>;
174-
// std::ptrdiff_t __offset = __parent_op_t::template __get_child_op_offset<__v<_Idx>>();
175-
// __parent_op_t* __parent = (__parent_op_t*) (static_cast<char*>(__child) - __offset);
176-
// return __t{__parent};
177-
// }
178-
179162
template <class... _Args>
180163
STDEXEC_ATTRIBUTE((always_inline)) void set_value(_Args&&... __args) noexcept {
181164
__op_->__complete(_Idx(), stdexec::set_value, static_cast<_Args&&>(__args)...);
@@ -198,11 +181,6 @@ namespace stdexec {
198181
};
199182
};
200183

201-
// template <class _Receiver>
202-
// using __sexpr_connected_with = __mapply<
203-
// __mbind_front_q<__m_at, typename _Receiver::__index>,
204-
// typename __call_result_t<__impl_of<typename _Receiver::__sexpr>, __cp, __get_desc>::__children>;
205-
206184
template <class _Sexpr, class _Receiver>
207185
using __state_t = //
208186
__state_type_t<typename __decay_t<_Sexpr>::__tag_t, _Sexpr, _Receiver>;
@@ -229,7 +207,7 @@ namespace stdexec {
229207
using __state_t = __state_type_t<__tag_t, _Sexpr, _Receiver>;
230208

231209
__state_box(_Sexpr&& __sndr, _Receiver& __rcvr) //
232-
noexcept(__nothrow_callable<decltype(__sexpr_impl<__tag_t>::get_state), _Sexpr, _Receiver>) {
210+
noexcept(__noexcept_of<__sexpr_impl<__tag_t>::get_state, _Sexpr, _Receiver&>) {
233211
::new (static_cast<void*>(__buf_)) auto(
234212
__sexpr_impl<__tag_t>::get_state(static_cast<_Sexpr&&>(__sndr), __rcvr));
235213
}
@@ -285,7 +263,7 @@ namespace stdexec {
285263
__op_base(_Sexpr&& __sndr, _Receiver&& __rcvr) //
286264
noexcept(
287265
__nothrow_decay_copyable<_Receiver>
288-
&& __nothrow_callable<decltype(__sexpr_impl<__tag_t>::get_state), _Sexpr, _Receiver>)
266+
&& __noexcept_of<__sexpr_impl<__tag_t>::get_state, _Sexpr, _Receiver&>)
289267
: __rcvr_(static_cast<_Receiver&&>(__rcvr))
290268
, __state_(__sexpr_impl<__tag_t>::get_state(static_cast<_Sexpr&&>(__sndr), __rcvr_)) {
291269
}
@@ -327,27 +305,6 @@ namespace stdexec {
327305
}
328306
};
329307

330-
// template <class _Sexpr, class _Receiver>
331-
// requires __is_instance_of<__id<_Receiver>, __receiver>
332-
// && __decays_to<_Sexpr, __sexpr_connected_with<_Receiver>>
333-
// struct __op_base<_Sexpr, _Receiver> : __immovable {
334-
// using __tag_t = typename __decay_t<_Sexpr>::__tag_t;
335-
// using __state_t = __state_type_t<__tag_t, _Sexpr, _Receiver>;
336-
337-
// STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS __state_t __state_;
338-
339-
// __op_base(_Sexpr&& __sndr, _Receiver&& __rcvr)
340-
// : __state_(__sexpr_impl<__tag_t>::get_state(static_cast<_Sexpr&&>(__sndr), __rcvr)) {
341-
// STDEXEC_ASSERT(this->__rcvr().__op_ == __rcvr.__op_);
342-
// }
343-
344-
// _Receiver __rcvr() const noexcept {
345-
// return _Receiver::__from_op_state( //
346-
// static_cast<__op_state<_Sexpr, _Receiver>*>( //
347-
// const_cast<__op_base*>(this)));
348-
// }
349-
// };
350-
351308
STDEXEC_PRAGMA_PUSH()
352309
STDEXEC_PRAGMA_IGNORE_GNU("-Wmissing-braces")
353310

@@ -380,29 +337,23 @@ namespace stdexec {
380337
return {};
381338
}
382339
};
340+
383341
STDEXEC_PRAGMA_POP()
384342

385343
template <class _Sexpr, class _Receiver>
386344
struct __op_state : __op_base<_Sexpr, _Receiver> {
387345
using __desc_t = typename __decay_t<_Sexpr>::__desc_t;
388346
using __tag_t = typename __desc_t::__tag;
389347
using __data_t = typename __desc_t::__data;
390-
//using __children_t = typename __desc_t::__children;
391348
using __state_t = typename __op_state::__state_t;
392349
using __inner_ops_t = __result_of<__sexpr_apply, _Sexpr, __connect_fn<_Sexpr, _Receiver>>;
393350

394351
__inner_ops_t __inner_ops_;
395352

396-
// template <std::size_t _Idx>
397-
// static std::ptrdiff_t __get_child_op_offset() noexcept {
398-
// __op_state* __self = (__op_state*) &__self;
399-
// return (std::ptrdiff_t)((char*) &__tup::get<_Idx>(__self->__inner_ops_) - static_cast<char*>(__self));
400-
// }
401-
402353
__op_state(_Sexpr&& __sexpr, _Receiver __rcvr) //
403354
noexcept(
404-
__nothrow_constructible_from<__op_base<_Sexpr, _Receiver>, _Sexpr&&, _Receiver&&>
405-
&& __nothrow_callable<__sexpr_apply_t, _Sexpr&&, __connect_fn<_Sexpr, _Receiver>>)
355+
__nothrow_constructible_from<__op_base<_Sexpr, _Receiver>, _Sexpr, _Receiver>
356+
&& __noexcept_of<__sexpr_apply, _Sexpr, __connect_fn<_Sexpr, _Receiver>>)
406357
: __op_state::__op_base{static_cast<_Sexpr&&>(__sexpr), static_cast<_Receiver&&>(__rcvr)}
407358
, __inner_ops_(
408359
__sexpr_apply(static_cast<_Sexpr&&>(__sexpr), __connect_fn<_Sexpr, _Receiver>{this})) {
@@ -468,7 +419,7 @@ namespace stdexec {
468419
decltype(__detail::__captures(_Tag(), __declval<_Data>(), __declval<_Child>()...));
469420

470421
template <class, class, class... _Child>
471-
using __tuple_size_t = char[sizeof...(_Child) + 2];
422+
using __tuple_size_t = char[sizeof...(_Child) + 2]; // NOLINT(modernize-avoid-c-arrays)
472423

473424
template <std::size_t _Idx, class _Descriptor>
474425
concept __in_range = (_Idx < sizeof(__minvoke<_Descriptor, __q<__tuple_size_t>>));

0 commit comments

Comments
 (0)