Skip to content

Commit

Permalink
give messages to static_asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed Dec 20, 2024
1 parent 5ddac4f commit 57ff710
Show file tree
Hide file tree
Showing 77 changed files with 1,395 additions and 1,362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

int main(int, char**)
{
static_assert(cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 0>>);
static_assert(cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 42>>);
static_assert(cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, cuda::std::dynamic_extent>>);
static_assert(!cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 42>&>);
static_assert(!cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 42> const>);
static_assert(cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 0>>, "");
static_assert(cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 42>>, "");
static_assert(cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, cuda::std::dynamic_extent>>, "");
static_assert(!cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 42>&>, "");
static_assert(!cuda::std::ranges::enable_borrowed_range<cuda::std::span<int, 42> const>, "");

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@

using range = cuda::std::span<int>;

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>, 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>);
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>, "");

int main(int, char**)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

#include "test_iterators.h"

static_assert(cuda::std::same_as<cuda::std::iter_reference_t<cpp17_input_iterator<int*>>, int&>);
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<forward_iterator<int*>>, int&>);
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<bidirectional_iterator<int*>>, int&>);
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<random_access_iterator<int*>>, int&>);
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<cpp17_input_iterator<int*>>, int&>, "");
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<forward_iterator<int*>>, int&>, "");
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<bidirectional_iterator<int*>>, int&>, "");
static_assert(cuda::std::same_as<cuda::std::iter_reference_t<random_access_iterator<int*>>, int&>, "");

int main(int, char**)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ int main(int, char**)
cuda::std::contiguous_iterator_tag tag;
((void) tag); // Prevent unused warning
static_assert(
(cuda::std::is_base_of<cuda::std::random_access_iterator_tag, cuda::std::contiguous_iterator_tag>::value));
static_assert((!cuda::std::is_base_of<cuda::std::output_iterator_tag, cuda::std::contiguous_iterator_tag>::value));
(cuda::std::is_base_of<cuda::std::random_access_iterator_tag, cuda::std::contiguous_iterator_tag>::value), "");
static_assert((!cuda::std::is_base_of<cuda::std::output_iterator_tag, cuda::std::contiguous_iterator_tag>::value),
"");

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,43 @@ struct CopyOnly
};

// Can copy the underlying objects between pointers.
static_assert(cuda::std::indirectly_copyable<int*, int*>);
static_assert(cuda::std::indirectly_copyable<const int*, int*>);
static_assert(cuda::std::indirectly_copyable<int*, int*>, "");
static_assert(cuda::std::indirectly_copyable<const int*, int*>, "");

// Can't copy if the output pointer is const.
static_assert(!cuda::std::indirectly_copyable<int*, const int*>);
static_assert(!cuda::std::indirectly_copyable<const int*, const int*>);
static_assert(!cuda::std::indirectly_copyable<int*, const int*>, "");
static_assert(!cuda::std::indirectly_copyable<const int*, const int*>, "");

// Can copy from a pointer into an array but arrays aren't considered indirectly copyable-from.
static_assert(cuda::std::indirectly_copyable<int*, int[2]>);
static_assert(!cuda::std::indirectly_copyable<int[2], int*>);
static_assert(!cuda::std::indirectly_copyable<int[2], int[2]>);
static_assert(!cuda::std::indirectly_copyable<int (&)[2], int (&)[2]>);
static_assert(cuda::std::indirectly_copyable<int*, int[2]>, "");
static_assert(!cuda::std::indirectly_copyable<int[2], int*>, "");
static_assert(!cuda::std::indirectly_copyable<int[2], int[2]>, "");
static_assert(!cuda::std::indirectly_copyable<int (&)[2], int (&)[2]>, "");

// Can't copy between non-pointer types.
static_assert(!cuda::std::indirectly_copyable<int*, int>);
static_assert(!cuda::std::indirectly_copyable<int, int*>);
static_assert(!cuda::std::indirectly_copyable<int, int>);
static_assert(!cuda::std::indirectly_copyable<int*, int>, "");
static_assert(!cuda::std::indirectly_copyable<int, int*>, "");
static_assert(!cuda::std::indirectly_copyable<int, int>, "");

// Check some less common types.
static_assert(!cuda::std::indirectly_movable<void*, void*>);
static_assert(!cuda::std::indirectly_movable<int*, void*>);
static_assert(!cuda::std::indirectly_movable<int(), int()>);
static_assert(!cuda::std::indirectly_movable<int*, int()>);
static_assert(!cuda::std::indirectly_movable<void, void>);
static_assert(!cuda::std::indirectly_movable<void*, void*>, "");
static_assert(!cuda::std::indirectly_movable<int*, void*>, "");
static_assert(!cuda::std::indirectly_movable<int(), int()>, "");
static_assert(!cuda::std::indirectly_movable<int*, int()>, "");
static_assert(!cuda::std::indirectly_movable<void, void>, "");

// Can't copy move-only objects.
static_assert(!cuda::std::indirectly_copyable<MoveOnly*, MoveOnly*>);
static_assert(!cuda::std::indirectly_copyable<MoveOnly*, const MoveOnly*>);
static_assert(!cuda::std::indirectly_copyable<const MoveOnly*, MoveOnly*>);
static_assert(!cuda::std::indirectly_copyable<const MoveOnly*, const MoveOnly*>);
static_assert(!cuda::std::indirectly_copyable<MoveOnly*, MoveOnly*>, "");
static_assert(!cuda::std::indirectly_copyable<MoveOnly*, const MoveOnly*>, "");
static_assert(!cuda::std::indirectly_copyable<const MoveOnly*, MoveOnly*>, "");
static_assert(!cuda::std::indirectly_copyable<const MoveOnly*, const MoveOnly*>, "");

// Can copy copy-only objects.
#ifndef TEST_COMPILER_MSVC_2017 // MSVC2017 has issues determining common_reference
static_assert(cuda::std::indirectly_copyable<CopyOnly*, CopyOnly*>);
static_assert(!cuda::std::indirectly_copyable<CopyOnly*, const CopyOnly*>);
static_assert(cuda::std::indirectly_copyable<const CopyOnly*, CopyOnly*>);
static_assert(!cuda::std::indirectly_copyable<const CopyOnly*, const CopyOnly*>);
static_assert(cuda::std::indirectly_copyable<CopyOnly*, CopyOnly*>, "");
static_assert(!cuda::std::indirectly_copyable<CopyOnly*, const CopyOnly*>, "");
static_assert(cuda::std::indirectly_copyable<const CopyOnly*, CopyOnly*>, "");
static_assert(!cuda::std::indirectly_copyable<const CopyOnly*, const CopyOnly*>, "");
#endif // TEST_COMPILER_MSVC_2017

template <class T>
Expand All @@ -77,13 +77,13 @@ struct PointerTo

#ifndef TEST_COMPILER_MSVC_2017 // MSVC2017 has issues determining common_reference
// Can copy through a dereferenceable class.
static_assert(cuda::std::indirectly_copyable<int*, PointerTo<int>>);
static_assert(!cuda::std::indirectly_copyable<int*, PointerTo<const int>>);
static_assert(cuda::std::indirectly_copyable<PointerTo<int>, PointerTo<int>>);
static_assert(!cuda::std::indirectly_copyable<PointerTo<int>, PointerTo<const int>>);
static_assert(cuda::std::indirectly_copyable<CopyOnly*, PointerTo<CopyOnly>>);
static_assert(cuda::std::indirectly_copyable<PointerTo<CopyOnly>, CopyOnly*>);
static_assert(cuda::std::indirectly_copyable<PointerTo<CopyOnly>, PointerTo<CopyOnly>>);
static_assert(cuda::std::indirectly_copyable<int*, PointerTo<int>>, "");
static_assert(!cuda::std::indirectly_copyable<int*, PointerTo<const int>>, "");
static_assert(cuda::std::indirectly_copyable<PointerTo<int>, PointerTo<int>>, "");
static_assert(!cuda::std::indirectly_copyable<PointerTo<int>, PointerTo<const int>>, "");
static_assert(cuda::std::indirectly_copyable<CopyOnly*, PointerTo<CopyOnly>>, "");
static_assert(cuda::std::indirectly_copyable<PointerTo<CopyOnly>, CopyOnly*>, "");
static_assert(cuda::std::indirectly_copyable<PointerTo<CopyOnly>, PointerTo<CopyOnly>>, "");
#endif // TEST_COMPILER_MSVC_2017

int main(int, char**)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ __host__ __device__ constexpr bool indirectly_copyable_subsumption()
return true;
}

static_assert(indirectly_copyable_subsumption<int*, int*>());
static_assert(indirectly_copyable_subsumption<int*, int*>(), "");

int main(int, char**)
{
Expand Down
Loading

0 comments on commit 57ff710

Please sign in to comment.