Skip to content

Commit

Permalink
Added template keyword in __tuple.hpp for member name disambiguation. (
Browse files Browse the repository at this point in the history
…#1432)

* Added template keyword in __tuple.hpp for member name disambiguation.

The mainline compilers accept the code as-is... for now.
CWG1835 is resolved with the template kw.
There's a recent patch waiting on-deck for Clang to require
template in this position: llvm/llvm-project#92957

Circle requires the token now.

* add workaround for gcc

* apply the workaround to nvc++ as well

---------

Co-authored-by: Eric Niebler <eniebler@nvidia.com>
  • Loading branch information
seanbaxter and ericniebler authored Dec 29, 2024
1 parent 150a82f commit 5f01147
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions include/stdexec/__detail/__tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@

#include <cstddef>

#if STDEXEC_GCC() || STDEXEC_NVHPC()
// GCC (as of v14) does not implement the resolution of CWG1835
// https://cplusplus.github.io/CWG/issues/1835.html
// See: https://godbolt.org/z/TzxrhK6ea
# define STDEXEC_NO_CWG1835
#endif

#ifdef STDEXEC_NO_CWG1835
# define STDEXEC_CWG1835_TEMPLATE
#else
# define STDEXEC_CWG1835_TEMPLATE template
#endif

namespace stdexec {
namespace __tup {
template <class _Ty, std::size_t _Idx>
Expand Down Expand Up @@ -56,24 +69,26 @@ namespace stdexec {
struct __tuple<_Idx, _Ts...> : __box<_Ts, _Is>... {
template <class... _Us>
static __tuple __convert_from(__tuple<_Idx, _Us...> &&__tup) {
return __tuple{{static_cast<_Us &&>(__tup.__box<_Us, _Is>::__value)}...};
return __tuple{
{static_cast<_Us &&>(__tup.STDEXEC_CWG1835_TEMPLATE __box<_Us, _Is>::__value)}...};
}

template <class... _Us>
static __tuple __convert_from(__tuple<_Idx, _Us...> const &__tup) {
return __tuple{{__tup.__box<_Us, _Is>::__value}...};
return __tuple{{__tup.STDEXEC_CWG1835_TEMPLATE __box<_Us, _Is>::__value}...};
}

template <class _Fn, class _Self, class... _Us>
STDEXEC_ATTRIBUTE((host, device, always_inline)) static auto apply(_Fn &&__fn, _Self &&__self, _Us &&...__us) //
noexcept(noexcept(static_cast<_Fn &&>(__fn)(
static_cast<_Us &&>(__us)...,
static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value...)))
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value...)))
-> decltype(static_cast<_Fn &&>(__fn)(
static_cast<_Us &&>(__us)...,
static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value...)) {
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value...)) {
return static_cast<_Fn &&>(__fn)(
static_cast<_Us &&>(__us)..., static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value...);
static_cast<_Us &&>(__us)...,
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value...);
}

template <class _Fn, class _Self, class... _Us>
Expand All @@ -82,7 +97,8 @@ namespace stdexec {
noexcept((__nothrow_callable<_Fn, _Us..., __copy_cvref_t<_Self, _Ts>> && ...)) -> void {
return (
static_cast<_Fn &&>(__fn)(
static_cast<_Us &&>(__us)..., static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value),
static_cast<_Us &&>(__us)...,
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value),
...);
}
};
Expand Down

0 comments on commit 5f01147

Please sign in to comment.