Skip to content

Commit 0cb8648

Browse files
committed
Work around bad MSVC bug regarding friend functions
1 parent 1472180 commit 0cb8648

File tree

1 file changed

+36
-21
lines changed
  • libcudacxx/include/cuda/std/detail/libcxx/include

1 file changed

+36
-21
lines changed

libcudacxx/include/cuda/std/detail/libcxx/include/tuple

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -656,20 +656,39 @@ class _LIBCUDACXX_TEMPLATE_VIS tuple
656656
struct _PackExpandsToThisTuple<_Arg> : is_same<__remove_cvref_t<_Arg>, tuple>
657657
{};
658658

659-
template <size_t _Jp, class... _Up>
660-
friend _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _LIBCUDACXX_INLINE_VISIBILITY __tuple_element_t<_Jp, tuple<_Up...>>& get(
661-
tuple<_Up...>&) noexcept;
662-
template <size_t _Jp, class... _Up>
663-
friend _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _LIBCUDACXX_INLINE_VISIBILITY const __tuple_element_t<_Jp, tuple<_Up...>>&
664-
get(const tuple<_Up...>&) noexcept;
665-
template <size_t _Jp, class... _Up>
666-
friend _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _LIBCUDACXX_INLINE_VISIBILITY __tuple_element_t<_Jp, tuple<_Up...>>&& get(
667-
tuple<_Up...>&&) noexcept;
668-
template <size_t _Jp, class... _Up>
669-
friend _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _LIBCUDACXX_INLINE_VISIBILITY const __tuple_element_t<_Jp, tuple<_Up...>>&&
670-
get(const tuple<_Up...>&&) noexcept;
671-
672659
public:
660+
template <size_t _Ip>
661+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple>&
662+
__get_impl() & noexcept
663+
{
664+
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;
665+
return static_cast<__tuple_leaf<_Ip, type>&>(__base_).get();
666+
}
667+
668+
template <size_t _Ip>
669+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple>&
670+
__get_impl() const& noexcept
671+
{
672+
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;
673+
return static_cast<const __tuple_leaf<_Ip, type>&>(__base_).get();
674+
}
675+
676+
template <size_t _Ip>
677+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple>&&
678+
__get_impl() && noexcept
679+
{
680+
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;
681+
return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__base_).get());
682+
}
683+
684+
template <size_t _Ip>
685+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple>&&
686+
__get_impl() const&& noexcept
687+
{
688+
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple> type;
689+
return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__base_).get());
690+
}
691+
673692
template < class _Constraints = __tuple_constraints<_Tp...>,
674693
__enable_if_t<_Constraints::__implicit_default_constructible, int> = 0>
675694
_LIBCUDACXX_INLINE_VISIBILITY constexpr tuple() noexcept(_Constraints::__nothrow_default_constructible)
@@ -919,32 +938,28 @@ template <size_t _Ip, class... _Tp>
919938
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple<_Tp...>>&
920939
get(tuple<_Tp...>& __t) noexcept
921940
{
922-
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple<_Tp...>> type;
923-
return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get();
941+
return __t.template __get_impl<_Ip>();
924942
}
925943

926944
template <size_t _Ip, class... _Tp>
927945
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple<_Tp...>>&
928946
get(const tuple<_Tp...>& __t) noexcept
929947
{
930-
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple<_Tp...>> type;
931-
return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get();
948+
return __t.template __get_impl<_Ip>();
932949
}
933950

934951
template <size_t _Ip, class... _Tp>
935952
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 __tuple_element_t<_Ip, tuple<_Tp...>>&&
936953
get(tuple<_Tp...>&& __t) noexcept
937954
{
938-
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple<_Tp...>> type;
939-
return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get());
955+
return _CUDA_VSTD::move(__t).template __get_impl<_Ip>();
940956
}
941957

942958
template <size_t _Ip, class... _Tp>
943959
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 const __tuple_element_t<_Ip, tuple<_Tp...>>&&
944960
get(const tuple<_Tp...>&& __t) noexcept
945961
{
946-
typedef _LIBCUDACXX_NODEBUG_TYPE __tuple_element_t<_Ip, tuple<_Tp...>> type;
947-
return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get());
962+
return static_cast<const tuple<_Tp...>&&>(__t).template __get_impl<_Ip>();
948963
}
949964

950965
#if _LIBCUDACXX_STD_VER > 11

0 commit comments

Comments
 (0)