[libcxx-commits] [libcxx] [libc++][NFC] Add additional tests for begin/end of std::ranges::take_view (PR #79085)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 1 16:05:19 PDT 2024
================
@@ -69,13 +81,51 @@ constexpr bool test() {
ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
}
- // simple-view<V> && sized_range<V> && !size_range<!V>
+ // simple-view<V> && sized_range<V> && !sized_range<const V>
{
+ static_assert(simple_view<NonCommonSimpleView>);
+ static_assert(std::ranges::sized_range<NonCommonSimpleView>);
+ static_assert(!std::ranges::sized_range<const NonCommonSimpleView>);
+
std::ranges::take_view<NonCommonSimpleView> tv{};
ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
ASSERT_SAME_TYPE(decltype(std::as_const(tv).begin()), std::counted_iterator<int*>);
}
+ // non simple-view<V> && !sized_range<V>
+ {
+ static_assert(!simple_view<NonSimpleNonSizedView>);
----------------
var-const wrote:
Consider creating an alias for the type being tested:
```cpp
using View = NonSimpleNonSizedView;
static_assert(!simple_view<View>);
...
```
That way, it would be much harder to introduce a copy-paste error and easier to manually verify the same type is being tested throughout the test case.
(applies throughout)
https://github.com/llvm/llvm-project/pull/79085
More information about the libcxx-commits
mailing list