Skip to content

Commit

Permalink
Merge pull request NVIDIA#1268 from NVIDIA/remove-explicit-this-macro
Browse files Browse the repository at this point in the history
remove unnecessary explicit-this portability macro
  • Loading branch information
ericniebler authored Mar 2, 2024
2 parents af4e218 + 19d89bc commit a0f8ebc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ Macros: [
'STDEXEC_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
'STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS=[[no_unique_address]]',
'STDEXEC_MISSING_MEMBER(X,Y)=true',
'STDEXEC_DEFINE_MEMBER(X)=void foo() {}',
'STDEXEC_DEFINE_EXPLICIT_THIS_MEMFN(...)=__VA_ARGS__'
'STDEXEC_DEFINE_MEMBER(X)=void foo() {}'
]
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
Expand Down
3 changes: 1 addition & 2 deletions include/exec/__detail/__basic_sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ namespace exec {
}

template <class _Sender, class _ApplyFn>
STDEXEC_DEFINE_EXPLICIT_THIS_MEMFN(auto apply)
(this _Sender&& __sndr, _ApplyFn&& __fun) //
static auto apply(_Sender&& __sndr, _ApplyFn&& __fun) //
noexcept(stdexec::__nothrow_callable<
stdexec::__detail::__impl_of<_Sender>,
stdexec::__copy_cvref_fn<_Sender>,
Expand Down
20 changes: 9 additions & 11 deletions include/stdexec/__detail/__basic_sender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ namespace stdexec {

inline constexpr auto __get_state = //
[]<class _Sender>(_Sender&& __sndr, __ignore) noexcept -> decltype(auto) {
return STDEXEC_CALL_EXPLICIT_THIS_MEMFN(static_cast<_Sender&&>(__sndr), apply)(__get_data());
return __sndr.apply(static_cast<_Sender&&>(__sndr), __get_data());
};

inline constexpr auto __connect = //
Expand Down Expand Up @@ -560,9 +560,10 @@ namespace stdexec {

template <class _Sender, class _ApplyFn>
STDEXEC_ATTRIBUTE((always_inline))
STDEXEC_DEFINE_EXPLICIT_THIS_MEMFN(auto apply)(this _Sender&& __sndr, _ApplyFn&& __fun) noexcept(
__nothrow_callable<__detail::__impl_of<_Sender>, __copy_cvref_fn<_Sender>, _ApplyFn>) //
-> __call_result_t<__detail::__impl_of<_Sender>, __copy_cvref_fn<_Sender>, _ApplyFn> { //
static auto
apply(_Sender&& __sndr, _ApplyFn&& __fun) noexcept(
__nothrow_callable<__detail::__impl_of<_Sender>, __copy_cvref_fn<_Sender>, _ApplyFn>) //
-> __call_result_t<__detail::__impl_of<_Sender>, __copy_cvref_fn<_Sender>, _ApplyFn> { //
return static_cast<_Sender&&>(__sndr).__impl_(
__copy_cvref_fn<_Sender>(), static_cast<_ApplyFn&&>(__fun)); //
}
Expand Down Expand Up @@ -632,13 +633,10 @@ namespace stdexec {
template <class _Sender, class _ApplyFn>
STDEXEC_ATTRIBUTE((always_inline))
auto
operator()(_Sender&& __sndr, _ApplyFn&& __fun) const
noexcept(noexcept(STDEXEC_CALL_EXPLICIT_THIS_MEMFN((static_cast<_Sender&&>(__sndr)), apply)(
static_cast<_ApplyFn&&>(__fun)))) //
-> decltype(STDEXEC_CALL_EXPLICIT_THIS_MEMFN((static_cast<_Sender&&>(__sndr)), apply)(
static_cast<_ApplyFn&&>(__fun))) {
return STDEXEC_CALL_EXPLICIT_THIS_MEMFN((static_cast<_Sender&&>(__sndr)), apply)(
static_cast<_ApplyFn&&>(__fun)); //
operator()(_Sender&& __sndr, _ApplyFn&& __fun) const noexcept(
noexcept(__sndr.apply(static_cast<_Sender&&>(__sndr), static_cast<_ApplyFn&&>(__fun)))) //
-> decltype(__sndr.apply(static_cast<_Sender&&>(__sndr), static_cast<_ApplyFn&&>(__fun))) {
return __sndr.apply(static_cast<_Sender&&>(__sndr), static_cast<_ApplyFn&&>(__fun)); //
}
};
} // namespace __detail
Expand Down
12 changes: 0 additions & 12 deletions include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,6 @@ enum {
# define STDEXEC_EXPLICIT_THIS(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
#endif

#if STDEXEC_EXPLICIT_THIS()
# define STDEXEC_DEFINE_EXPLICIT_THIS_MEMFN(...) __VA_ARGS__
# define STDEXEC_CALL_EXPLICIT_THIS_MEMFN(_OBJ, _NAME) (_OBJ)._NAME( STDEXEC_CALL_EXPLICIT_THIS_MEMFN_DETAIL
# define STDEXEC_CALL_EXPLICIT_THIS_MEMFN_DETAIL(...) __VA_ARGS__ )
#else
# define STDEXEC_DEFINE_EXPLICIT_THIS_MEMFN(...) static __VA_ARGS__(STDEXEC_FUN_ARGS
# define STDEXEC_CALL_EXPLICIT_THIS_MEMFN(_OBJ, _NAME) (_OBJ)._NAME((_OBJ) STDEXEC_CALL_EXPLICIT_THIS_MEMFN_DETAIL
# define STDEXEC_CALL_EXPLICIT_THIS_MEMFN_DETAIL(...) __VA_OPT__(, ) __VA_ARGS__)
# define STDEXEC_EAT_THIS_DETAIL_this
# define STDEXEC_FUN_ARGS(...) STDEXEC_CAT(STDEXEC_EAT_THIS_DETAIL_, __VA_ARGS__))
#endif

// Configure extra type checking
#define STDEXEC_TYPE_CHECKING_ZERO() 0
#define STDEXEC_TYPE_CHECKING_ONE() 1
Expand Down
10 changes: 3 additions & 7 deletions include/stdexec/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,10 +3034,8 @@ namespace stdexec {

explicit __local_state(_CvrefSender&& __sndr) noexcept
: __local_state::__local_state_base{{}, &__action<tag_of_t<_CvrefSender>>}
, __shared_state_(
STDEXEC_CALL_EXPLICIT_THIS_MEMFN(static_cast<_CvrefSender&&>(__sndr), apply)(
__detail::__get_data())
.__shared_state) {
, __shared_state_(__sndr.apply(static_cast<_CvrefSender&&>(__sndr), __detail::__get_data())
.__shared_state) {
}

~__local_state() {
Expand Down Expand Up @@ -3791,9 +3789,7 @@ namespace stdexec {
_Sched __sched = query_or(
get_completion_scheduler<_Set>, stdexec::get_env(__sndr), __none_such());
return __let_state_t{
STDEXEC_CALL_EXPLICIT_THIS_MEMFN(static_cast<_Sender&&>(__sndr), apply)(
__detail::__get_data()),
__sched};
__sndr.apply(static_cast<_Sender&&>(__sndr), __detail::__get_data()), __sched};
};

template <class _State, class _Receiver, class... _As>
Expand Down

0 comments on commit a0f8ebc

Please sign in to comment.