//===----------------------------------------------------------------------===// // // 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 // concept checking // // template // concept has-tuple-element = // tuple-like && N < tuple_size_v; // // template // concept returnable-element = // is_reference_v || move_constructible>; // // template // requires view && has-tuple-element, N> && // has-tuple-element>, N> && // returnable-element, N> // class elements_view; #include #include #include #include #include #include "test_iterators.h" template using Range = std::ranges::subrange>; template concept HasElementsView = requires { typename std::ranges::elements_view; }; static_assert(HasElementsView*>, 0>); static_assert(HasElementsView*>, 1>); static_assert(HasElementsView*>, 2>); static_assert(HasElementsView*>, 3>); // !view static_assert(!std::ranges::view, 1>>); static_assert(!HasElementsView, 1>, 0>); // !input_range static_assert(!std::ranges::input_range*>>>); static_assert(!HasElementsView*>>, 0>); // !tuple-like LIBCPP_STATIC_ASSERT(!std::__tuple_like); static_assert(!HasElementsView, 1>); // !(N < tuple_size_v) static_assert(!(2 < std::tuple_size_v< std::pair>)); static_assert(!HasElementsView*>, 2>); // ! (is_reference_v || move_constructible>) struct NonMovable { NonMovable(int) {} NonMovable(NonMovable&&) = delete; }; static_assert(!std::move_constructible); using NonMovableGenerator = decltype(std::views::iota(0, 1) | std::views::transform([](int) { return std::pair{1, 1}; })); static_assert(!HasElementsView); static_assert(HasElementsView);