Skip to content

Commit

Permalink
simplify the definition of the basic_any class template (#3085)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Michael Schellenberger Costa <[email protected]>
  • Loading branch information
ericniebler and miscco authored Dec 9, 2024
1 parent dcc0b22 commit cdb714f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ struct hierarchy_dimensions_fragment
: levels(ls)
{}

# if !defined(_CCCL_NO_THREE_WAY_COMPARISON) && !_CCCL_COMPILER(MSVC, <, 19, 39)
# if !defined(_CCCL_NO_THREE_WAY_COMPARISON) && !_CCCL_COMPILER(MSVC, <, 19, 39) && !_CCCL_COMPILER(GCC, <, 12)
_CCCL_NODISCARD _CCCL_HIDE_FROM_ABI constexpr bool
operator==(const hierarchy_dimensions_fragment&) const noexcept = default;
# else // ^^^ !_CCCL_NO_THREE_WAY_COMPARISON ^^^ / vvv _CCCL_NO_THREE_WAY_COMPARISON vvv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct level_dimensions
_CCCL_HOST_DEVICE constexpr level_dimensions()
: dims(){};

# if !defined(_CCCL_NO_THREE_WAY_COMPARISON) && !_CCCL_COMPILER(MSVC, <, 19, 39)
# if !defined(_CCCL_NO_THREE_WAY_COMPARISON) && !_CCCL_COMPILER(MSVC, <, 19, 39) && !_CCCL_COMPILER(GCC, <, 12)
_CCCL_NODISCARD _CCCL_HIDE_FROM_ABI constexpr bool operator==(const level_dimensions&) const noexcept = default;
# else // ^^^ !_CCCL_NO_THREE_WAY_COMPARISON ^^^ / vvv _CCCL_NO_THREE_WAY_COMPARISON vvv
_CCCL_NODISCARD_FRIEND _CUDAX_API constexpr bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template <class _Interface, int = 0>
struct __basic_any_base : __interface_of<_Interface>
{
private:
template <class, class>
template <class>
friend struct basic_any;
friend struct __basic_any_access;

Expand Down Expand Up @@ -99,7 +99,7 @@ struct __basic_any_base<_Interface, 2> : __interface_of<_Interface> // copyable
}

private:
template <class, class>
template <class>
friend struct basic_any;
friend struct __basic_any_access;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ _CCCL_PUSH_MACROS

namespace cuda::experimental
{
struct __primary;
struct __secondary;

template <class _Interface>
struct __ireference;

template <class _Interface, class _Select = __primary>
template <class _Interface>
struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any;

template <class _Interface, class _Select>
struct _LIBCUDACXX_DECLSPEC_EMPTY_BASES basic_any<__ireference<_Interface>, _Select>;
template <class _Interface>
struct _LIBCUDACXX_DECLSPEC_EMPTY_BASES basic_any<__ireference<_Interface>>;

template <class _Interface>
struct basic_any<_Interface*>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface*>
#endif // _CCCL_DOXYGEN_INVOKED

private:
template <class, class>
template <class>
friend struct basic_any;
friend struct __basic_any_access;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ _CCCL_NV_DIAG_SUPPRESS(554)
//!
//! `basic_any<__ireference<_Interface>>` is neither copyable nor movable. It is
//! not an end-user type.
template <class _Interface, class Select>
struct _LIBCUDACXX_DECLSPEC_EMPTY_BASES basic_any<__ireference<_Interface>, Select>
template <class _Interface>
struct _LIBCUDACXX_DECLSPEC_EMPTY_BASES basic_any<__ireference<_Interface>>
: __interface_of<__ireference<_Interface>>
#if defined(_CCCL_NO_CONCEPTS)
, __basic_any_reference_conversion_base<_Interface>
Expand Down Expand Up @@ -157,7 +157,7 @@ struct _LIBCUDACXX_DECLSPEC_EMPTY_BASES basic_any<__ireference<_Interface>, Sele
#endif // _CCCL_DOXYGEN_INVOKED

private:
template <class, class>
template <class>
friend struct basic_any;
friend struct __basic_any_access;

Expand Down Expand Up @@ -256,14 +256,14 @@ _CCCL_DIAG_POP
//! basic_any<_Interface&>
//!
template <class _Interface>
struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__ireference<_Interface>, __secondary>
struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__ireference<_Interface>>
{
static_assert(_CUDA_VSTD::is_class_v<_Interface>, "expecting a class type");
using typename basic_any<__ireference<_Interface>, __secondary>::interface_type;
using basic_any<__ireference<_Interface>, __secondary>::__is_const_ref;
using typename basic_any<__ireference<_Interface>>::interface_type;
using basic_any<__ireference<_Interface>>::__is_const_ref;

_CUDAX_HOST_API basic_any(basic_any const& __other) noexcept
: basic_any<__ireference<_Interface>, __secondary>()
: basic_any<__ireference<_Interface>>()
{
this->__set_ref(__other.__get_vptr(), __other.__get_optr());
}
Expand All @@ -272,7 +272,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__irefer
_CCCL_REQUIRES((!__is_basic_any<_Tp>) _CCCL_AND __satisfies<_Up, interface_type> _CCCL_AND(
__is_const_ref || !_CUDA_VSTD::is_const_v<_Tp>))
_CUDAX_HOST_API basic_any(_Tp& __obj) noexcept
: basic_any<__ireference<_Interface>, __secondary>()
: basic_any<__ireference<_Interface>>()
{
__vptr_for<interface_type> const __vptr = &__vtable_for_v<interface_type, _Up>;
this->__set_ref(__vptr, &__obj);
Expand Down Expand Up @@ -300,7 +300,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__irefer
(!__is_value_v<_SrcInterface>) _CUDAX_AND //
__any_convertible_to<basic_any<_SrcInterface>, basic_any>)
_CUDAX_HOST_API basic_any(basic_any<_SrcInterface>&& __src) noexcept
: basic_any<__ireference<_Interface>, __secondary>()
: basic_any<__ireference<_Interface>>()
{
this->__set_ref(__src.__get_vptr(), __src.__get_optr());
}
Expand All @@ -309,7 +309,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__irefer
_CUDAX_REQUIRES((!_CUDA_VSTD::same_as<_SrcInterface, _Interface&>) _CUDAX_AND //
__any_convertible_to<basic_any<_SrcInterface>&, basic_any>)
_CUDAX_HOST_API basic_any(basic_any<_SrcInterface>& __src) noexcept
: basic_any<__ireference<_Interface>, __secondary>()
: basic_any<__ireference<_Interface>>()
{
this->__set_ref(__src.__get_vptr(), __src.__get_optr());
}
Expand All @@ -318,7 +318,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__irefer
_CUDAX_REQUIRES((!_CUDA_VSTD::same_as<_SrcInterface, _Interface&>) _CUDAX_AND //
__any_convertible_to<basic_any<_SrcInterface> const&, basic_any>)
_CUDAX_HOST_API basic_any(basic_any<_SrcInterface> const& __src) noexcept
: basic_any<__ireference<_Interface>, __secondary>()
: basic_any<__ireference<_Interface>>()
{
this->__set_ref(__src.__get_vptr(), __src.__get_optr());
}
Expand All @@ -343,7 +343,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any<_Interface&> : basic_any<__irefer
}

private:
template <class, class>
template <class>
friend struct basic_any;
friend struct __basic_any_access;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _CCCL_CONCEPT __list_initializable_from =
//!
//! basic_any
//!
template <class _Interface, class>
template <class _Interface>
struct _CCCL_TYPE_VISIBILITY_DEFAULT basic_any : __basic_any_base<_Interface>
{
private:
Expand Down Expand Up @@ -362,7 +362,7 @@ public:
#endif // _CCCL_DOXYGEN_INVOKED

private:
template <class, class>
template <class>
friend struct basic_any;
friend struct __basic_any_access;
template <class, int>
Expand Down

0 comments on commit cdb714f

Please sign in to comment.