//===----------------------------------------------------------------------===// // // 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 // constexpr auto end(); // constexpr auto end() const requires range; #include #include #include #include #include "test_macros.h" #include "test_iterators.h" #include "types.h" constexpr bool test() { int buf[8] = {1, 2, 3, 4, 5, 6, 7, 8}; { SizedRandomAccessView view{buf, buf + 8}; std::ranges::common_view common(view); std::same_as auto end = common.end(); // Note this should NOT be the sentinel type. assert(base(end) == buf + 8); } // const version { SizedRandomAccessView view{buf, buf + 8}; std::ranges::common_view const common(view); std::same_as auto end = common.end(); // Note this should NOT be the sentinel type. assert(base(end) == buf + 8); } return true; } int main(int, char**) { test(); static_assert(test()); { int buf[8] = {1, 2, 3, 4, 5, 6, 7, 8}; using CommonForwardIter = std::common_iterator>; using CommonIntIter = std::common_iterator>; { SizedForwardView view{buf, buf + 8}; std::ranges::common_view common(view); std::same_as auto end = common.end(); assert(end == CommonForwardIter(std::ranges::end(view))); } { CopyableView view{buf, buf + 8}; std::ranges::common_view common(view); std::same_as auto end = common.end(); assert(end == CommonIntIter(std::ranges::end(view))); } // const versions { SizedForwardView view{buf, buf + 8}; std::ranges::common_view const common(view); std::same_as auto end = common.end(); assert(end == CommonForwardIter(std::ranges::end(view))); } { CopyableView view{buf, buf + 8}; std::ranges::common_view const common(view); std::same_as auto end = common.end(); assert(end == CommonIntIter(std::ranges::end(view))); } } return 0; }