Skip to content

Commit

Permalink
Do not require contiguous_iterator_tag in C++17 as that is not sati…
Browse files Browse the repository at this point in the history
…sfied by any standard container
  • Loading branch information
miscco committed Oct 23, 2024
1 parent a8dd691 commit ca506a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 0 additions & 1 deletion libcudacxx/include/cuda/std/__iterator/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ _LIBCUDACXX_CONCEPT_FRAGMENT(
__contiguous_iterator_,
requires(const _Ip& __i)(
requires(random_access_iterator<_Ip>),
requires(derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag>),
requires(is_lvalue_reference_v<iter_reference_t<_Ip>>),
requires(same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>>),
requires(same_as<add_pointer_t<iter_reference_t<_Ip>>, decltype(_CUDA_VSTD::to_address(__i))>)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

#include "test_macros.h"

#if !defined(TEST_COMPILER_NVRTC)
# include <vector>
#endif // !TEST_COMPILER_NVRTC

// Look ma - I'm a container!
template <typename T>
struct IsAContainer
Expand Down Expand Up @@ -136,6 +140,19 @@ __host__ __device__ void testRuntimeSpanStatic()
assert(s2.data() == cVal.getV() && s2.size() == 1);
}

#if !defined(TEST_COMPILER_NVRTC)
template <typename T>
void testContainers()
{
::std::vector<T> val(1);
const ::std::vector<T> cVal(1);
cuda::std::span<T> s1{val};
cuda::std::span<const T> s2{cVal};
assert(s1.data() == val.data() && s1.size() == 1);
assert(s2.data() == cVal.data() && s2.size() == 1);
}
#endif // !TEST_COMPILER_NVRTC

struct A
{};

Expand Down Expand Up @@ -163,5 +180,9 @@ int main(int, char**)

checkCV();

#if !defined(TEST_COMPILER_NVRTC)
NV_IF_TARGET(NV_IS_HOST, (testContainers<int>(); testContainers<A>();))
#endif // !TEST_COMPILER_NVRTC

return 0;
}

0 comments on commit ca506a4

Please sign in to comment.