//===----------------------------------------------------------------------===// // // 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, c++20 // // // template> // struct std::ranges::elements_of; // // template> // elements_of(R&&, Allocator = Allocator()) -> elements_of; #include #include #include #include #include #include "min_allocator.h" #include "test_allocator.h" #include "test_iterators.h" template constexpr void test_impl() { Allocator a; // With a lvalue range { Range r; std::ranges::elements_of elements(r); static_assert(std::same_as>>); } // With a rvalue range { Range r; std::ranges::elements_of elements(std::move(r)); static_assert(std::same_as>>); } // With lvalue range and allocator { Range r; std::ranges::elements_of elements(r, a); static_assert(std::same_as>); } // With rvalue range and allocator { Range r; std::ranges::elements_of elements(std::move(r), Allocator()); static_assert(std::same_as>); } // Ensure we can use designated initializers { // lvalues { Range r; std::ranges::elements_of elements{.range = r, .allocator = a}; static_assert(std::same_as>); } // rvalues { Range r; std::ranges::elements_of elements{.range = std::move(r), .allocator = Allocator()}; static_assert(std::same_as>); } } } template struct Range { Iterator begin() const; sentinel_wrapper end() const; }; constexpr bool test() { types::for_each(types::type_list, min_allocator, test_allocator>{}, [] { types::for_each(types::cpp20_input_iterator_list{}, [] { test_impl>(); }); }); return true; } int main(int, char**) { test(); static_assert(test()); return 0; }