diff --git a/libcxx/include/__ranges/subrange.h b/libcxx/include/__ranges/subrange.h --- a/libcxx/include/__ranges/subrange.h +++ b/libcxx/include/__ranges/subrange.h @@ -226,6 +226,9 @@ else return __subrange.end(); } + + template + inline constexpr bool enable_borrowed_range> = true; } // namespace ranges using ranges::get; diff --git a/libcxx/include/ranges b/libcxx/include/ranges --- a/libcxx/include/ranges +++ b/libcxx/include/ranges @@ -93,6 +93,16 @@ requires is_class_v && same_as> class view_interface; + // [range.subrange], sub-ranges + enum class subrange_kind : bool { unsized, sized }; + + template S = I, subrange_kind K = see below> + requires (K == subrange_kind::sized || !sized_sentinel_for) + class subrange; + + template + inline constexpr bool enable_borrowed_range> = true; + // [range.empty], empty view template requires is_object_v diff --git a/libcxx/test/std/ranges/range.utility/range.subrange/enable_borrowed_range.compile.pass.cpp b/libcxx/test/std/ranges/range.utility/range.subrange/enable_borrowed_range.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/ranges/range.utility/range.subrange/enable_borrowed_range.compile.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// UNSUPPORTED: libcpp-no-concepts +// UNSUPPORTED: gcc-10 + +// class std::ranges::subrange; + +#include + +#include "test_iterators.h" + +namespace ranges = std::ranges; + +static_assert(ranges::borrowed_range>); +static_assert(ranges::borrowed_range>); +static_assert(ranges::borrowed_range, ranges::subrange_kind::unsized>>);