Skip to content

Commit

Permalink
just enough ranges for c++14 span
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed Dec 20, 2024
1 parent 67c075a commit 4bda0d7
Show file tree
Hide file tree
Showing 85 changed files with 143 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <cuda/std/__concepts/totally_ordered.h>
#include <cuda/std/__utility/forward.h>

#if _CCCL_STD_VER >= 2017
#if _CCCL_STD_VER >= 2014

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES
_LIBCUDACXX_BEGIN_NAMESPACE_RANGES_ABI
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ concept indirectly_copyable_storable =
// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle
// (both iter_swap and indirectly_swappable require indirectly_readable).

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

// [iterator.concept.readable]
template <class _In>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/incrementable_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ using iter_difference_t =
incrementable_traits<remove_cvref_t<_Ip>>,
iterator_traits<remove_cvref_t<_Ip>>>::difference_type;

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

// [incrementable.traits]
template <class, class = void>
Expand Down Expand Up @@ -150,7 +150,7 @@ using iter_difference_t =
incrementable_traits<remove_cvref_t<_Ip>>,
iterator_traits<remove_cvref_t<_Ip>>>::difference_type;

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <class _Iter1, class _Iter2, class _BinaryPred, class _Proj1 = identity
concept indirectly_comparable =
indirect_binary_predicate<_BinaryPred, projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

// clang-format off

Expand All @@ -50,7 +50,7 @@ _CCCL_CONCEPT indirectly_comparable =

// clang-format on

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/iter_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wvoid-ptr-dereference")

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

// [iterator.cust.move]

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/iter_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <cuda/std/__utility/forward.h>
#include <cuda/std/__utility/move.h>

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

// [iter.cust.swap]

Expand Down Expand Up @@ -158,6 +158,6 @@ _CCCL_INLINE_VAR constexpr bool __noexcept_swappable<_I1, _I2, enable_if_t<indir

_LIBCUDACXX_END_NAMESPACE_STD

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

#endif // _LIBCUDACXX___ITERATOR_ITER_SWAP_H
10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__iterator/iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ using iter_reference_t = decltype(*declval<_Tp&>());
template <class>
struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits;

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

template <class _Tp>
using __with_reference = _Tp&;
Expand All @@ -119,10 +119,10 @@ using iter_reference_t = enable_if_t<__dereferenceable<_Tp>, decltype(*declval<_

template <class, class>
struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits;
#else // ^^^ _CCCL_STD_VER > 2014 ^^^ / vvv _CCCL_STD_VER <= 2014 vvv
#else // ^^^ _CCCL_STD_VER >= 2014 ^^^ / vvv _CCCL_STD_VER < 2014 vvv
template <class>
struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits;
#endif // _CCCL_STD_VER <= 2014
#endif // _CCCL_STD_VER < 2014

#if _CCCL_COMPILER(NVRTC)

Expand Down Expand Up @@ -511,7 +511,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits : __iterator_traits<_Ip>
using __primary_template = iterator_traits;
};

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^ / vvv _CCCL_STD_VER > 2014 vvv
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^ / vvv _CCCL_STD_VER > 2014 vvv

// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
// from `[iterator.cpp17]`. To avoid confusion between the two, the exposition-only concepts have been banished to
Expand Down Expand Up @@ -841,7 +841,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits<_Tp*>
typedef _Tp* pointer;
typedef typename add_lvalue_reference<_Tp>::type reference;
typedef random_access_iterator_tag iterator_category;
#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014
typedef contiguous_iterator_tag iterator_concept;
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/mergeable.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ concept mergeable =
&& indirectly_copyable<_Input1, _Output> && indirectly_copyable<_Input2, _Output>
&& indirect_strict_weak_order<_Comp, projected<_Input1, _Proj1>, projected<_Input2, _Proj2>>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

template <class _Input1, class _Input2, class _Output, class _Comp, class _Proj1, class _Proj2>
_CCCL_CONCEPT_FRAGMENT(
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/permutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ template <class _Iterator>
concept permutable = forward_iterator<_Iterator> && indirectly_movable_storable<_Iterator, _Iterator>
&& indirectly_swappable<_Iterator, _Iterator>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

template <class _Iterator>
_CCCL_CONCEPT_FRAGMENT(__permutable_,
Expand All @@ -43,7 +43,7 @@ _CCCL_CONCEPT_FRAGMENT(__permutable_,
template <class _Iterator>
_CCCL_CONCEPT permutable = _CCCL_FRAGMENT(__permutable_, _Iterator);

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/projected.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

template <class _It, class _Proj, class = void>
struct __projected_impl
Expand All @@ -54,7 +54,7 @@ _CCCL_TEMPLATE(class _It, class _Proj)
_CCCL_REQUIRES(indirectly_readable<_It> _CCCL_AND indirectly_regular_unary_invocable<_Proj, _It>)
using projected = typename __projected_impl<_It, _Proj>::__type;

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/readable_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ using iter_value_t =
indirectly_readable_traits<remove_cvref_t<_Ip>>,
iterator_traits<remove_cvref_t<_Ip>>>::value_type;

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

// [readable.traits]
template <class, class = void>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/sortable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD
template <class _Iter, class _Comp = _CUDA_VRANGES::less, class _Proj = identity>
concept sortable = permutable<_Iter> && indirect_strict_weak_order<_Comp, projected<_Iter, _Proj>>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

template <class _Iter, class _Comp, class _Proj>
_CCCL_CONCEPT_FRAGMENT(
Expand All @@ -44,7 +44,7 @@ _CCCL_CONCEPT_FRAGMENT(
template <class _Iter, class _Comp = _CUDA_VRANGES::less, class _Proj = identity>
_CCCL_CONCEPT sortable = _CCCL_FRAGMENT(__sortable_, _Iter, _Comp, _Proj);

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__ranges/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER > 2014 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017)

template <class _Tp>
_CCCL_CONCEPT __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>;
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__ranges/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017)

# if !defined(_CCCL_NO_CONCEPTS)

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017)

// [range.prim.data]

Expand Down Expand Up @@ -128,7 +128,7 @@ inline namespace __cpo
_CCCL_GLOBAL_CONSTANT auto cdata = __cdata::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017)

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# pragma system_header
#endif // no system header

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/enable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017
#if _CCCL_STD_VER >= 2014

struct view_base
{};
Expand Down Expand Up @@ -74,7 +74,7 @@ _CCCL_INLINE_VAR constexpr bool
true;
# endif // _CCCL_NO_CONCEPTS

#endif // _CCCL_STD_VER >= 2017
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
13 changes: 3 additions & 10 deletions libcudacxx/include/cuda/std/__ranges/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014 && !_CCCL_COMPILER(MSVC2017)

template <class>
_CCCL_INLINE_VAR constexpr bool disable_sized_range = false;
Expand Down Expand Up @@ -182,15 +182,8 @@ struct __fn
noexcept(noexcept(_CUDA_VRANGES::size(__t)))
{
using _Signed = make_signed_t<decltype(_CUDA_VRANGES::size(__t))>;
if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))
{
return static_cast<ptrdiff_t>(_CUDA_VRANGES::size(__t));
}
else
{
return static_cast<_Signed>(_CUDA_VRANGES::size(__t));
}
_CCCL_UNREACHABLE();
using _Result = conditional_t<(sizeof(ptrdiff_t) > sizeof(_Signed)), ptrdiff_t, _Signed>;
return static_cast<_Result>(_CUDA_VRANGES::size(__t));
}
};
_LIBCUDACXX_END_NAMESPACE_CPO
Expand Down
Loading

0 comments on commit 4bda0d7

Please sign in to comment.