| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 | |
| 11 | // constexpr drop_view(V base, range_difference_t<V> count); // explicit since C++23 |
| 12 | |
| 13 | #include <ranges> |
| 14 | |
| 15 | #include "test_convertible.h" |
| 16 | #include "test_macros.h" |
| 17 | #include "types.h" |
| 18 | |
| 19 | // SFINAE tests. |
| 20 | |
| 21 | #if TEST_STD_VER >= 23 |
| 22 | |
| 23 | static_assert(!test_convertible<std::ranges::drop_view<View>, View, std::ranges::range_difference_t<View>>(), |
| 24 | "This constructor must be explicit" ); |
| 25 | |
| 26 | #else |
| 27 | |
| 28 | static_assert(test_convertible<std::ranges::drop_view<View>, View, std::ranges::range_difference_t<View>>(), |
| 29 | "This constructor must not be explicit" ); |
| 30 | |
| 31 | #endif // TEST_STD_VER >= 23 |
| 32 | |
| 33 | constexpr bool test() { |
| 34 | std::ranges::drop_view dropView1(MoveOnlyView(), 4); |
| 35 | assert(dropView1.size() == 4); |
| 36 | assert(dropView1.begin() == globalBuff + 4); |
| 37 | |
| 38 | std::ranges::drop_view dropView2(ForwardView(), 4); |
| 39 | assert(base(dropView2.begin()) == globalBuff + 4); |
| 40 | |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | int main(int, char**) { |
| 45 | test(); |
| 46 | static_assert(test()); |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |