Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Avoid use of inline variables in C++14 #478

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions include/cuda/memory_resource
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ _LIBCUDACXX_CONCEPT async_resource = _LIBCUDACXX_FRAGMENT(__async_resource_, _Re
template <class _Resource, class... _Properties>
#if _LIBCUDACXX_STD_VER < 17
_LIBCUDACXX_CONCEPT resource_with =
resource<_Resource>&& _CUDA_VSTD::conjunction_v<_CUDA_VSTD::bool_constant<has_property<_Resource, _Properties>>...>;
resource<_Resource>&& _CUDA_VSTD::conjunction<_CUDA_VSTD::bool_constant<has_property<_Resource, _Properties>>...>::value;
#else
_LIBCUDACXX_CONCEPT resource_with = resource<_Resource> && (has_property<_Resource, _Properties> && ...);
#endif
Expand All @@ -245,7 +245,7 @@ _LIBCUDACXX_CONCEPT resource_with = resource<_Resource> && (has_property<_Resour
template <class _Resource, class... _Properties>
#if _LIBCUDACXX_STD_VER < 17
_LIBCUDACXX_CONCEPT async_resource_with = async_resource<_Resource> &&
_CUDA_VSTD::conjunction_v<_CUDA_VSTD::bool_constant<has_property<_Resource, _Properties>>...>;
_CUDA_VSTD::conjunction<_CUDA_VSTD::bool_constant<has_property<_Resource, _Properties>>...>::value;
#else
_LIBCUDACXX_CONCEPT async_resource_with = async_resource<_Resource> &&
(has_property<_Resource, _Properties> && ...);
Expand Down Expand Up @@ -432,7 +432,7 @@ using _Filtered_vtable = typename _Filtered<_Properties...>::_Filtered_vtable::_
template <class _Vtable>
struct _Alloc_base
{
static_assert(cuda::std::is_base_of_v<_Alloc_vtable, _Vtable>, "");
static_assert(_LIBCUDACXX_TRAIT(cuda::std::is_base_of, _Alloc_vtable, _Vtable), "");

_Alloc_base(void* __object_, const _Vtable* __static_vtabl_) noexcept
: __object(__object_)
Expand All @@ -457,7 +457,7 @@ protected:
template <class _Vtable>
struct _Async_alloc_base : public _Alloc_base<_Vtable>
{
static_assert(cuda::std::is_base_of_v<_Async_alloc_vtable, _Vtable>, "");
static_assert(_LIBCUDACXX_TRAIT(cuda::std::is_base_of, _Async_alloc_vtable, _Vtable), "");

_Async_alloc_base(void* __object_, const _Vtable* __static_vtabl_) noexcept
: _Alloc_base<_Vtable>(__object_, __static_vtabl_)
Expand Down Expand Up @@ -535,8 +535,8 @@ public:
(requires (_CUDA_VSTD::_One_of<_Properties, _OtherProperties...> && ...))
#else
_LIBCUDACXX_TEMPLATE(class... _OtherProperties)
(requires _CUDA_VSTD::conjunction_v<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>)
(requires _CUDA_VSTD::conjunction<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>::value)
#endif
basic_resource_ref(
basic_resource_ref<_Alloc_type, _OtherProperties...> __ref) noexcept
Expand All @@ -551,8 +551,8 @@ public:
#else
_LIBCUDACXX_TEMPLATE(class... _OtherProperties)
(requires (_Alloc_type == _AllocType::_Default)
&& _CUDA_VSTD::conjunction_v<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>)
&& _CUDA_VSTD::conjunction<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>::value)
#endif
basic_resource_ref(
basic_resource_ref<_AllocType::_Async, _OtherProperties...> __ref) noexcept
Expand All @@ -567,8 +567,8 @@ public:
#else
_LIBCUDACXX_TEMPLATE(class... _OtherProperties)
(requires (sizeof...(_Properties) == sizeof...(_OtherProperties))
&& _CUDA_VSTD::conjunction_v<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>)
&& _CUDA_VSTD::conjunction<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>::value)
#endif
bool operator==(
const basic_resource_ref<_Alloc_type, _OtherProperties...> &__right) const {
Expand All @@ -583,8 +583,8 @@ public:
#else
_LIBCUDACXX_TEMPLATE(class... _OtherProperties)
(requires (sizeof...(_Properties) == sizeof...(_OtherProperties))
&& _CUDA_VSTD::conjunction_v<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>)
&& _CUDA_VSTD::conjunction<_CUDA_VSTD::bool_constant<
_CUDA_VSTD::_One_of<_Properties, _OtherProperties...>>...>::value)
#endif
bool operator!=(
const basic_resource_ref<_Alloc_type, _OtherProperties...> &__right) const {
Expand Down
64 changes: 46 additions & 18 deletions include/cuda/std/detail/libcxx/include/__concepts/destructible.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,54 +24,82 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if _LIBCUDACXX_STD_VER > 11 && _GNUC_VER < 1100
#if _LIBCUDACXX_STD_VER > 11

// [concept.destructible]

#if defined(_LIBCUDACXX_COMPILER_GCC) && _GNUC_VER < 1100

template<class _Tp>
_LIBCUDACXX_CONCEPT destructible = is_nothrow_destructible_v<_Tp>;
_LIBCUDACXX_CONCEPT destructible = _LIBCUDACXX_TRAIT(is_nothrow_destructible, _Tp);

#else
// [concept.destructible]
#if _LIBCUDACXX_STD_VER > 17
#else // ^^^ _LIBCUDACXX_COMPILER_GCC && GCC < 11 ^^^ / vvv other compilers vvv

#if _LIBCUDACXX_STD_VER > 17 // use concepts

template<class _Tp>
constexpr bool __destructible_impl = false;
inline constexpr bool __destructible_impl_v = false;

template<class _Tp>
requires requires(_Tp& __t) { { __t.~_Tp() } noexcept; }
constexpr bool __destructible_impl<_Tp> = true;
inline constexpr bool __destructible_impl_v<_Tp> = true;

#elif _LIBCUDACXX_STD_VER > 11
#else // ^^^ _LIBCUDACXX_STD_VER > 17 ^^^ / vvv _LIBCUDACXX_STD_VER < 20 vvv

template<class _Tp>
_LIBCUDACXX_CONCEPT_FRAGMENT(
__destructible_impl_req_,
requires(_Tp& __t)(
requires(is_object_v<_Tp>),
requires(_LIBCUDACXX_TRAIT(is_object, _Tp)),
requires(noexcept(__t.~_Tp()))
));

template<class _Tp>
constexpr bool __destructible_impl = _LIBCUDACXX_FRAGMENT(__destructible_impl_req_, _Tp);
#endif // _LIBCUDACXX_STD_VER > 11
struct __destructible_impl : public _BoolConstant<_LIBCUDACXX_FRAGMENT(__destructible_impl_req_, _Tp)> {};

#if _LIBCUDACXX_STD_VER > 14
template<class _Tp>
inline constexpr bool __destructible_impl_v = _LIBCUDACXX_FRAGMENT(__destructible_impl_req_, _Tp);
#endif // _LIBCUDACXX_STD_VER > 14

#endif // _LIBCUDACXX_STD_VER < 20

#if _LIBCUDACXX_STD_VER > 14 // inline variables

#if _LIBCUDACXX_STD_VER > 11
template<class _Tp>
constexpr bool __destructible = __destructible_impl<_Tp>;
inline constexpr bool __destructible_v = __destructible_impl_v<_Tp>;

template<class _Tp>
constexpr bool __destructible<_Tp&> = true;
inline constexpr bool __destructible_v<_Tp&> = true;

template<class _Tp>
constexpr bool __destructible<_Tp&&> = true;
inline constexpr bool __destructible_v<_Tp&&> = true;

template<class _Tp, size_t _Nm>
constexpr bool __destructible<_Tp[_Nm]> = __destructible<_Tp>;
inline constexpr bool __destructible_v<_Tp[_Nm]> = __destructible_v<_Tp>;

#else // ^^^ _LIBCUDACXX_STD_VER > 14 ^^^ / vvv _LIBCUDACXX_STD_VER < 17 vvv

template<class _Tp>
struct __destructible : public __destructible_impl<_Tp> {};

template<class _Tp>
_LIBCUDACXX_CONCEPT destructible = __destructible<_Tp>;
struct __destructible<_Tp&> : public true_type {};

template<class _Tp>
struct __destructible<_Tp&&> : public true_type {};

template<class _Tp, size_t _Nm>
struct __destructible<_Tp[_Nm]> : public __destructible<_Tp> {};

#endif // _LIBCUDACXX_STD_VER < 17

template<class _Tp>
_LIBCUDACXX_CONCEPT destructible = _LIBCUDACXX_TRAIT(__destructible, _Tp);

#endif // !_LIBCUDACXX_COMPILER_GCC || __GNUC__ > 11

#endif // _LIBCUDACXX_STD_VER > 11
#endif // _GNUC_VER < 1100

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ template<class _Tp>
_LIBCUDACXX_CONCEPT_FRAGMENT(
_Movable_,
requires()
(requires(is_object_v<_Tp>),
(requires(_LIBCUDACXX_TRAIT(is_object, _Tp)),
requires(move_constructible<_Tp>),
requires(assignable_from<_Tp&, _Tp>),
requires(swappable<_Tp>)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
template <class _Fn, class ..._Args>
_LIBCUDACXX_INLINE_VISIBILITY constexpr invoke_result_t<_Fn, _Args...>
invoke(_Fn&& __f, _Args&&... __args)
noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_invocable, _Fn, _Args...))
{
return _CUDA_VSTD::__invoke(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward<_Args>(__args)...);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class layout_left::mapping {
using layout_type = layout_left;
private:

static_assert(__detail::__is_extents_v<extents_type>, "layout_left::mapping must be instantiated with a specialization of _CUDA_VSTD::extents.");
static_assert(__detail::__is_extents<extents_type>::value, "layout_left::mapping must be instantiated with a specialization of _CUDA_VSTD::extents.");

template <class>
friend class mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class layout_right::mapping {
using layout_type = layout_right;
private:

static_assert(__detail::__is_extents_v<extents_type>, "layout_right::mapping must be instantiated with a specialization of _CUDA_VSTD::extents.");
static_assert(__detail::__is_extents<extents_type>::value, "layout_right::mapping must be instantiated with a specialization of _CUDA_VSTD::extents.");

template <class>
friend class mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct layout_stride {
using layout_type = layout_stride;

// This could be a `requires`, but I think it's better and clearer as a `static_assert`.
static_assert(__detail::__is_extents_v<_Extents>, "layout_stride::mapping must be instantiated with a specialization of _CUDA_VSTD::extents.");
static_assert(__detail::__is_extents<_Extents>::value, "layout_stride::mapping must be instantiated with a specialization of _CUDA_VSTD::extents.");


private:
Expand Down
6 changes: 3 additions & 3 deletions include/cuda/std/detail/libcxx/include/__mdspan/mdspan.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ template <
class mdspan
{
private:
static_assert(__detail::__is_extents_v<_Extents>, "mdspan's Extents template parameter must be a specialization of _CUDA_VSTD::extents.");
static_assert(__detail::__is_extents<_Extents>::value, "mdspan's Extents template parameter must be a specialization of _CUDA_VSTD::extents.");

// Workaround for non-deducibility of the index sequence template parameter if it's given at the top level
template <class>
Expand Down Expand Up @@ -431,9 +431,9 @@ __MDSPAN_TEMPLATE_REQUIRES(
mdspan(_Pointer&&) -> mdspan<_CUDA_VSTD::remove_pointer_t<_CUDA_VSTD::remove_reference_t<_Pointer>>, extents<size_t>>;
__MDSPAN_TEMPLATE_REQUIRES(
class _CArray,
(_LIBCUDACXX_TRAIT(is_array, _CArray) && (rank_v<_CArray> == 1))
(_LIBCUDACXX_TRAIT(is_array, _CArray) && (_LIBCUDACXX_TRAIT(rank, _CArray) == 1))
)
mdspan(_CArray&) -> mdspan<_CUDA_VSTD::remove_all_extents_t<_CArray>, extents<size_t, _CUDA_VSTD::extent_v<_CArray,0>>>;
mdspan(_CArray&) -> mdspan<_CUDA_VSTD::remove_all_extents_t<_CArray>, extents<size_t, _LIBCUDACXX_TRAIT(_CUDA_VSTD::extent, _CArray, 0)>>;

template <class _ElementType, class _SizeType, size_t _Np>
mdspan(_ElementType*, const _CUDA_VSTD::array<_SizeType, _Np>&)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ struct __cond_res_workaround {};
template <class _Tp, class _Up>
struct __cond_res_workaround<_Tp, _Up, void_t<__cond_res_if_right<_Tp, _Up>>> {
using _RTp = remove_cvref_t<_Tp>;
using type = conditional_t<is_same_v<_RTp, remove_cvref_t<_Up>> &&
(is_scalar_v<_RTp> || is_array_v<_RTp>) &&
((is_lvalue_reference_v<_Tp> && is_rvalue_reference_v<_Up>) || (is_rvalue_reference_v<_Tp> && is_lvalue_reference_v<_Up>)),
using type = conditional_t<_LIBCUDACXX_TRAIT(is_same, _RTp, remove_cvref_t<_Up>)
&& (_LIBCUDACXX_TRAIT(is_scalar, _RTp) || _LIBCUDACXX_TRAIT(is_array, _RTp))
&& ((_LIBCUDACXX_TRAIT(is_lvalue_reference, _Tp) && _LIBCUDACXX_TRAIT(is_rvalue_reference, _Up))
||(_LIBCUDACXX_TRAIT(is_rvalue_reference, _Tp) && _LIBCUDACXX_TRAIT(is_lvalue_reference, _Up))),
decay_t<__copy_cv_t<remove_reference_t<_Tp>, remove_reference_t<_Up>>>, __cond_res_if_right<_Tp, _Up>>;
};

Expand Down Expand Up @@ -93,7 +94,7 @@ using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>
// If A and B are both lvalue reference types, COMMON-REF(A, B) is
// COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type.
template<class _Ap, class _Bp>
struct __common_ref<_Ap&, _Bp&, enable_if_t<is_reference_v<__cv_cond_res<_Ap, _Bp>>>>
struct __common_ref<_Ap&, _Bp&, enable_if_t<_LIBCUDACXX_TRAIT(is_reference, __cv_cond_res<_Ap, _Bp>)>>
{
using __type = __cv_cond_res<_Ap, _Bp>;
};
Expand All @@ -110,8 +111,8 @@ struct __common_ref_rr {};

template<class _Ap, class _Bp>
struct __common_ref_rr<_Ap&&, _Bp&&, enable_if_t<
is_convertible_v<_Ap&&, __common_ref_C<_Ap, _Bp>>
&& is_convertible_v<_Bp&&, __common_ref_C<_Ap, _Bp>>>>
_LIBCUDACXX_TRAIT(is_convertible, _Ap&&, __common_ref_C<_Ap, _Bp>)
&& _LIBCUDACXX_TRAIT(is_convertible, _Bp&&, __common_ref_C<_Ap, _Bp>)>>
{
using __type = __common_ref_C<_Ap, _Bp>;
};
Expand All @@ -129,7 +130,7 @@ template<class _Ap, class _Bp, class = void>
struct __common_ref_lr {};

template<class _Ap, class _Bp>
struct __common_ref_lr<_Ap&&, _Bp&, enable_if_t<is_convertible_v<_Ap&&, __common_ref_D<_Ap, _Bp>>>>
struct __common_ref_lr<_Ap&&, _Bp&, enable_if_t<_LIBCUDACXX_TRAIT(is_convertible, _Ap&&, __common_ref_D<_Ap, _Bp>)>>
{
using __type = __common_ref_D<_Ap, _Bp>;
};
Expand Down Expand Up @@ -178,7 +179,7 @@ template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_ref

template <class _Tp, class _Up>
struct __common_reference_sub_bullet1<_Tp, _Up, void_t<__common_ref_t<_Tp, _Up>,
enable_if_t<is_reference_v<_Tp> && is_reference_v<_Up>>>>
enable_if_t<_LIBCUDACXX_TRAIT(is_reference, _Tp) && _LIBCUDACXX_TRAIT(is_reference, _Up)>>>
{
using type = __common_ref_t<_Tp, _Up>;
};
Expand Down
10 changes: 5 additions & 5 deletions include/cuda/std/detail/libcxx/include/cstddef
Original file line number Diff line number Diff line change
Expand Up @@ -136,31 +136,31 @@ constexpr byte operator~ (byte __b) noexcept

template <class _Integer>
_LIBCUDACXX_INLINE_VISIBILITY
constexpr __enable_if_t<is_integral_v<_Integer>, byte> &
constexpr __enable_if_t<_LIBCUDACXX_TRAIT(is_integral, _Integer), byte> &
operator<<=(byte& __lhs, _Integer __shift) noexcept
{ return __lhs = __lhs << __shift; }

template <class _Integer>
_LIBCUDACXX_INLINE_VISIBILITY
constexpr __enable_if_t<is_integral_v<_Integer>, byte>
constexpr __enable_if_t<_LIBCUDACXX_TRAIT(is_integral, _Integer), byte>
operator<< (byte __lhs, _Integer __shift) noexcept
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }

template <class _Integer>
_LIBCUDACXX_INLINE_VISIBILITY
constexpr __enable_if_t<is_integral_v<_Integer>, byte> &
constexpr __enable_if_t<_LIBCUDACXX_TRAIT(is_integral, _Integer), byte> &
operator>>=(byte& __lhs, _Integer __shift) noexcept
{ return __lhs = __lhs >> __shift; }

template <class _Integer>
_LIBCUDACXX_INLINE_VISIBILITY
constexpr __enable_if_t<is_integral_v<_Integer>, byte>
constexpr __enable_if_t<_LIBCUDACXX_TRAIT(is_integral, _Integer), byte>
operator>> (byte __lhs, _Integer __shift) noexcept
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }

template <class _Integer>
_LIBCUDACXX_INLINE_VISIBILITY
constexpr __enable_if_t<is_integral_v<_Integer>, _Integer>
constexpr __enable_if_t<_LIBCUDACXX_TRAIT(is_integral, _Integer), _Integer>
to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }

#ifdef _LIBCUDACXX_END_NAMESPACE_STD_NOVERSION
Expand Down