Skip to content

Commit

Permalink
Replace thrust::detail::integral_constant with libcudacxx implementat…
Browse files Browse the repository at this point in the history
…ion (#561)

This replaces thrust::integral_constant with `cuda::std::integral_constant`

Co-authored-by: Michael Schellenberger Costa <[email protected]>
  • Loading branch information
ZelboK and miscco authored Oct 17, 2023
1 parent a8971b4 commit b269438
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
.aws
.config
_deps/catch2-src/
.vscode/
compile_commands.json
CMakeUserPresets.json
2 changes: 1 addition & 1 deletion thrust/thrust/detail/functional/actor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ template<typename Eval>
// met.
template <typename T>
using actor_check_ref_type =
thrust::detail::integral_constant<bool,
::cuda::std::integral_constant<bool,
( std::is_lvalue_reference<T>::value ||
thrust::detail::is_wrapped_reference<T>::value )>;

Expand Down
40 changes: 8 additions & 32 deletions thrust/thrust/detail/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,10 @@ template<typename T> class device_reference;
namespace detail
{
/// helper classes [4.3].
template<typename T, T v>
struct integral_constant
{
THRUST_INLINE_INTEGRAL_MEMBER_CONSTANT T value = v;

typedef T value_type;
typedef integral_constant<T, v> type;

// We don't want to switch to std::integral_constant, because we want access
// to the C++14 operator(), but we'd like standard traits to interoperate
// with our version when tag dispatching.
integral_constant() = default;

integral_constant(integral_constant const&) = default;

integral_constant& operator=(integral_constant const&) = default;

constexpr __host__ __device__
integral_constant(std::integral_constant<T, v>) noexcept {}

constexpr __host__ __device__ operator value_type() const noexcept { return value; }
constexpr __host__ __device__ value_type operator()() const noexcept { return value; }
};

/// typedef for true_type
typedef integral_constant<bool, true> true_type;

/// typedef for true_type
typedef integral_constant<bool, false> false_type;
template<typename T, T v>
using integral_constant = ::cuda::std::integral_constant<T, v>;
using true_type = ::cuda::std::true_type;
using false_type = ::cuda::std::false_type;

//template<typename T> struct is_integral : public std::tr1::is_integral<T> {};
template<typename T> struct is_integral : public false_type {};
Expand Down Expand Up @@ -275,7 +250,8 @@ template<typename T1, typename T2>

#if THRUST_CPP_DIALECT >= 2011

using std::is_convertible;
template<class From, class To>
using is_convertible = ::cuda::std::is_convertible<From, To>;

#else

Expand Down Expand Up @@ -559,7 +535,8 @@ template<typename T1, typename T2>

#if THRUST_CPP_DIALECT >= 2011

using std::is_base_of;
template<class Base, class Derived>
using is_base_of = ::cuda::std::is_base_of<Base, Derived>;

#else

Expand Down Expand Up @@ -721,4 +698,3 @@ using detail::false_type;
THRUST_NAMESPACE_END

#include <thrust/detail/type_traits/has_trivial_assign.h>

0 comments on commit b269438

Please sign in to comment.