Skip to content

Commit

Permalink
Workaround an nvcc bug (GridTools#1681)
Browse files Browse the repository at this point in the history
Fix a problem where nvcc doesn't distinguish type and non-type template parameters of template template parameters. See https://godbolt.org/z/orrev1xnM
  • Loading branch information
anstaf authored and havogt committed Apr 11, 2023
1 parent d4457d1 commit 497fc62
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions include/gridtools/common/tuple_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ namespace gridtools {
template <class Fun>
struct get_fun_result {
template <class... Ts>
using apply = decltype(std::declval<Fun const &>()(std::declval<Ts>()...));
using apply = decltype(std::declval<std::add_lvalue_reference_t<std::add_const_t<Fun>>>()(std::declval<Ts>()...));
};

template <class Tup>
Expand Down Expand Up @@ -1495,13 +1495,27 @@ namespace gridtools {
* convert_to<std::array>(some_tuple_like);
* convert_to<gridtools::array, int>(some_tuple_like);
*/
template <template <class...> class L>
template <template <class...> class L
#if defined(__NVCC__) && defined(__CUDACC_VER_MAJOR__) && \
(__CUDACC_VER_MAJOR__ < 11 || __CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ <= 8) \
&& __cplusplus >= 201703
// workaround against nvcc bug: https://godbolt.org/z/orrev1xnM
, int = 0, class = std::void_t<L<int, int>>
#endif
>
GT_TARGET GT_FORCE_INLINE GT_CONSTEXPR detail::convert_to_f<_impl::to_tuple_converter_helper<L>>
convert_to() {
return {};
}

template <template <class...> class L, class Tup>
template <template <class...> class L
#if defined(__NVCC__) && defined(__CUDACC_VER_MAJOR__) && \
(__CUDACC_VER_MAJOR__ < 11 || __CUDACC_VER_MAJOR__ == 11 && __CUDACC_VER_MINOR__ <= 8) \
&& __cplusplus >= 201703
// workaround against nvcc bug: https://godbolt.org/z/orrev1xnM
, int = 0, class = std::void_t<L<int, int>>
#endif
, class Tup>
GT_TARGET GT_FORCE_INLINE GT_CONSTEXPR auto convert_to(Tup && tup) {
return detail::convert_to_f<_impl::to_tuple_converter_helper<L>>{}(wstd::forward<Tup>(tup));
}
Expand Down

0 comments on commit 497fc62

Please sign in to comment.