Skip to content

Commit 5f01147

Browse files
Added template keyword in __tuple.hpp for member name disambiguation. (NVIDIA#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 <[email protected]>
1 parent 150a82f commit 5f01147

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

include/stdexec/__detail/__tuple.hpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222

2323
#include <cstddef>
2424

25+
#if STDEXEC_GCC() || STDEXEC_NVHPC()
26+
// GCC (as of v14) does not implement the resolution of CWG1835
27+
// https://cplusplus.github.io/CWG/issues/1835.html
28+
// See: https://godbolt.org/z/TzxrhK6ea
29+
# define STDEXEC_NO_CWG1835
30+
#endif
31+
32+
#ifdef STDEXEC_NO_CWG1835
33+
# define STDEXEC_CWG1835_TEMPLATE
34+
#else
35+
# define STDEXEC_CWG1835_TEMPLATE template
36+
#endif
37+
2538
namespace stdexec {
2639
namespace __tup {
2740
template <class _Ty, std::size_t _Idx>
@@ -56,24 +69,26 @@ namespace stdexec {
5669
struct __tuple<_Idx, _Ts...> : __box<_Ts, _Is>... {
5770
template <class... _Us>
5871
static __tuple __convert_from(__tuple<_Idx, _Us...> &&__tup) {
59-
return __tuple{{static_cast<_Us &&>(__tup.__box<_Us, _Is>::__value)}...};
72+
return __tuple{
73+
{static_cast<_Us &&>(__tup.STDEXEC_CWG1835_TEMPLATE __box<_Us, _Is>::__value)}...};
6074
}
6175

6276
template <class... _Us>
6377
static __tuple __convert_from(__tuple<_Idx, _Us...> const &__tup) {
64-
return __tuple{{__tup.__box<_Us, _Is>::__value}...};
78+
return __tuple{{__tup.STDEXEC_CWG1835_TEMPLATE __box<_Us, _Is>::__value}...};
6579
}
6680

6781
template <class _Fn, class _Self, class... _Us>
6882
STDEXEC_ATTRIBUTE((host, device, always_inline)) static auto apply(_Fn &&__fn, _Self &&__self, _Us &&...__us) //
6983
noexcept(noexcept(static_cast<_Fn &&>(__fn)(
7084
static_cast<_Us &&>(__us)...,
71-
static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value...)))
85+
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value...)))
7286
-> decltype(static_cast<_Fn &&>(__fn)(
7387
static_cast<_Us &&>(__us)...,
74-
static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value...)) {
88+
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value...)) {
7589
return static_cast<_Fn &&>(__fn)(
76-
static_cast<_Us &&>(__us)..., static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value...);
90+
static_cast<_Us &&>(__us)...,
91+
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value...);
7792
}
7893

7994
template <class _Fn, class _Self, class... _Us>
@@ -82,7 +97,8 @@ namespace stdexec {
8297
noexcept((__nothrow_callable<_Fn, _Us..., __copy_cvref_t<_Self, _Ts>> && ...)) -> void {
8398
return (
8499
static_cast<_Fn &&>(__fn)(
85-
static_cast<_Us &&>(__us)..., static_cast<_Self &&>(__self).__box<_Ts, _Is>::__value),
100+
static_cast<_Us &&>(__us)...,
101+
static_cast<_Self &&>(__self).STDEXEC_CWG1835_TEMPLATE __box<_Ts, _Is>::__value),
86102
...);
87103
}
88104
};

0 commit comments

Comments
 (0)