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

thrust::iterator_traits to inherit from std::iterator_traits #1491

Merged
merged 1 commit into from
Jul 21, 2021
Merged
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
50 changes: 1 addition & 49 deletions thrust/iterator/iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,59 +38,11 @@
namespace thrust
{

namespace detail
{

template <typename T, typename = void>
struct iterator_traits_impl {};

template <typename T>
struct iterator_traits_impl<
T
, typename voider<
typename T::difference_type
, typename T::value_type
, typename T::pointer
, typename T::reference
, typename T::iterator_category
>::type
>
{
typedef typename T::difference_type difference_type;
typedef typename T::value_type value_type;
typedef typename T::pointer pointer;
typedef typename T::reference reference;
typedef typename T::iterator_category iterator_category;
};

} // namespace detail

/*! \p iterator_traits is a type trait class that provides a uniform
* interface for querying the properties of iterators at compile-time.
*/
template <typename T>
struct iterator_traits : detail::iterator_traits_impl<T> {};

// traits are specialized for pointer types
template<typename T>
struct iterator_traits<T*>
{
typedef std::ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef std::random_access_iterator_tag iterator_category;
};

template<typename T>
struct iterator_traits<const T*>
{
typedef std::ptrdiff_t difference_type;
typedef T value_type;
typedef const T* pointer;
typedef const T& reference;
typedef std::random_access_iterator_tag iterator_category;
}; // end iterator_traits
struct iterator_traits : std::iterator_traits<T> {};

template<typename Iterator> struct iterator_value;

Expand Down