-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
libcudacxx/include/cuda/std/detail/libcxx/include/__ranges/enable_view.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCUDACXX___RANGES_ENABLE_VIEW_H | ||
#define _LIBCUDACXX___RANGES_ENABLE_VIEW_H | ||
|
||
#ifndef __cuda_std__ | ||
#include <__config> | ||
#endif // __cuda_std__ | ||
|
||
#include "../__concepts/derived_from.h" | ||
#include "../__concepts/same_as.h" | ||
#include "../__type_traits/enable_if.h" | ||
#include "../__type_traits/is_class.h" | ||
#include "../__type_traits/remove_cv.h" | ||
#include "../__type_traits/void_t.h" | ||
|
||
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) | ||
# pragma GCC system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) | ||
# pragma clang system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) | ||
# pragma system_header | ||
#endif // no system header | ||
_LIBCUDACXX_BEGIN_NAMESPACE_RANGES | ||
|
||
#if _LIBCUDACXX_STD_VER > 14 | ||
|
||
struct view_base { }; | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_RANGES_ABI | ||
|
||
#if _LIBCUDACXX_STD_VER > 17 | ||
|
||
template<class _Derived> | ||
requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>> | ||
class view_interface; | ||
|
||
#else | ||
|
||
template<class _Derived, enable_if_t<is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>>, int> = 0> | ||
class view_interface; | ||
|
||
#endif // _LIBCUDACXX_STD_VER < 17 | ||
|
||
_LIBCUDACXX_END_NAMESPACE_RANGES_ABI | ||
|
||
_LIBCUDACXX_TEMPLATE(class _Op, class _Yp) | ||
_LIBCUDACXX_REQUIRES(is_convertible_v<_Op*, view_interface<_Yp>*>) | ||
_LIBCUDACXX_INLINE_VISIBILITY | ||
void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*); | ||
|
||
#if _LIBCUDACXX_STD_VER > 17 | ||
|
||
template <class _Tp> | ||
_LIBCUDACXX_INLINE_VAR constexpr bool enable_view = derived_from<_Tp, view_base> || | ||
requires { _CUDA_VRANGES::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr); }; | ||
|
||
#else | ||
|
||
template <class _Tp, class = void> | ||
_LIBCUDACXX_INLINE_VAR constexpr bool enable_view = derived_from<_Tp, view_base>; | ||
|
||
template <class _Tp> | ||
_LIBCUDACXX_INLINE_VAR constexpr bool enable_view<_Tp, | ||
void_t<decltype(_CUDA_VRANGES::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr))>> = true; | ||
#endif // _LIBCUDACXX_STD_VER < 17 | ||
|
||
#endif // _LIBCUDACXX_STD_VER > 14 | ||
|
||
_LIBCUDACXX_END_NAMESPACE_RANGES | ||
|
||
#endif // _LIBCUDACXX___RANGES_ENABLE_VIEW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...xx/libcxx/test/std/containers/views/views.span/range_concept_conformance.compile.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
// UNSUPPORTED: msvc-19.16 | ||
|
||
// span | ||
|
||
#include <span> | ||
|
||
#include <concepts> | ||
#include <ranges> | ||
|
||
using range = std::span<int>; | ||
|
||
#ifdef _LIBCUDACXX_HAS_RANGES | ||
static_assert(std::same_as<std::ranges::iterator_t<range>, range::iterator>); | ||
static_assert(std::ranges::common_range<range>); | ||
static_assert(std::ranges::random_access_range<range>); | ||
static_assert(std::ranges::contiguous_range<range>); | ||
static_assert(std::ranges::view<range> && std::ranges::enable_view<range>); | ||
static_assert(std::ranges::sized_range<range>); | ||
static_assert(std::ranges::borrowed_range<range>); | ||
static_assert(std::ranges::viewable_range<range>); | ||
|
||
static_assert(std::same_as<std::ranges::iterator_t<range const>, range::iterator>); | ||
static_assert(std::ranges::common_range<range const>); | ||
static_assert(std::ranges::random_access_range<range const>); | ||
static_assert(std::ranges::contiguous_range<range const>); | ||
static_assert(!std::ranges::view<range const> && !std::ranges::enable_view<range const>); | ||
static_assert(std::ranges::sized_range<range const>); | ||
static_assert(std::ranges::borrowed_range<range const>); | ||
static_assert(std::ranges::viewable_range<range const>); | ||
#endif // _LIBCUDACXX_HAS_RANGES | ||
|
||
int main(int, char**) | ||
{ | ||
return 0; | ||
} |
45 changes: 45 additions & 0 deletions
45
libcudacxx/test/libcudacxx/std/views/views.span/range_concept_conformance.compile.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14 | ||
// UNSUPPORTED: msvc-19.16 | ||
|
||
// span | ||
|
||
#include <cuda/std/span> | ||
|
||
#include <cuda/std/concepts> | ||
#include <cuda/std/ranges> | ||
|
||
using range = cuda::std::span<int>; | ||
|
||
#ifdef _LIBCUDACXX_HAS_RANGES | ||
static_assert(cuda::std::same_as<cuda::std::ranges::iterator_t<range>, range::iterator>); | ||
static_assert(cuda::std::ranges::common_range<range>); | ||
static_assert(cuda::std::ranges::random_access_range<range>); | ||
static_assert(cuda::std::ranges::contiguous_range<range>); | ||
static_assert(cuda::std::ranges::view<range> && cuda::std::ranges::enable_view<range>); | ||
static_assert(cuda::std::ranges::sized_range<range>); | ||
static_assert(cuda::std::ranges::borrowed_range<range>); | ||
static_assert(cuda::std::ranges::viewable_range<range>); | ||
|
||
static_assert(cuda::std::same_as<cuda::std::ranges::iterator_t<range const>, range::iterator>); | ||
static_assert(cuda::std::ranges::common_range<range const>); | ||
static_assert(cuda::std::ranges::random_access_range<range const>); | ||
static_assert(cuda::std::ranges::contiguous_range<range const>); | ||
static_assert(!cuda::std::ranges::view<range const> && !cuda::std::ranges::enable_view<range const>); | ||
static_assert(cuda::std::ranges::sized_range<range const>); | ||
static_assert(cuda::std::ranges::borrowed_range<range const>); | ||
static_assert(cuda::std::ranges::viewable_range<range const>); | ||
#endif // _LIBCUDACXX_HAS_RANGES | ||
|
||
int main(int, char**) | ||
{ | ||
return 0; | ||
} |