From 3618ec4705e9c642384c683eb8d80ee3cd6b7f9e Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 6 Aug 2020 15:41:55 -0600 Subject: [PATCH] replace safe_subrange_t with borrowed_subrange_t --- include/range/v3/algorithm/equal_range.hpp | 2 +- include/range/v3/algorithm/find_end.hpp | 2 +- include/range/v3/algorithm/rotate.hpp | 2 +- include/range/v3/algorithm/search.hpp | 2 +- include/range/v3/algorithm/search_n.hpp | 2 +- include/range/v3/view/subrange.hpp | 12 ++++++++++-- test/view/subrange.cpp | 4 ++-- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/range/v3/algorithm/equal_range.hpp b/include/range/v3/algorithm/equal_range.hpp index 0a3f3c7fca..f8e0ea6427 100644 --- a/include/range/v3/algorithm/equal_range.hpp +++ b/include/range/v3/algorithm/equal_range.hpp @@ -105,7 +105,7 @@ namespace ranges /// \pre requires forward_range AND indirect_strict_weak_order, P>>) - safe_subrange_t // + borrowed_subrange_t // RANGES_FUNC(equal_range)(Rng && rng, V const & val, C pred = C{}, P proj = P{}) // { if(RANGES_CONSTEXPR_IF(sized_range)) diff --git a/include/range/v3/algorithm/find_end.hpp b/include/range/v3/algorithm/find_end.hpp index 340d92d419..89ef3139a2 100644 --- a/include/range/v3/algorithm/find_end.hpp +++ b/include/range/v3/algorithm/find_end.hpp @@ -217,7 +217,7 @@ namespace ranges /// \pre requires forward_range AND forward_range AND indirect_relation, P>, iterator_t>) - safe_subrange_t RANGES_FUNC(find_end)( + borrowed_subrange_t RANGES_FUNC(find_end)( Rng1 && rng1, Rng2 && rng2, R pred = R{}, P proj = P{}) // { return (*this)(begin(rng1), diff --git a/include/range/v3/algorithm/rotate.hpp b/include/range/v3/algorithm/rotate.hpp index 4e8713e24e..5a0b6976b2 100644 --- a/include/range/v3/algorithm/rotate.hpp +++ b/include/range/v3/algorithm/rotate.hpp @@ -217,7 +217,7 @@ namespace ranges template(typename Rng, typename I = iterator_t)( /// \pre requires range AND permutable) - safe_subrange_t RANGES_FUNC(rotate)(Rng && rng, I middle) // + borrowed_subrange_t RANGES_FUNC(rotate)(Rng && rng, I middle) // { return (*this)(begin(rng), std::move(middle), end(rng)); } diff --git a/include/range/v3/algorithm/search.hpp b/include/range/v3/algorithm/search.hpp index ecf1b54099..62fdcaa7fc 100644 --- a/include/range/v3/algorithm/search.hpp +++ b/include/range/v3/algorithm/search.hpp @@ -197,7 +197,7 @@ namespace ranges /// \pre requires forward_range AND forward_range AND indirectly_comparable, iterator_t, C, P1, P2>) - safe_subrange_t RANGES_FUNC(search)( + borrowed_subrange_t RANGES_FUNC(search)( Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{}, P2 proj2 = P2{}) // { if(empty(rng2)) diff --git a/include/range/v3/algorithm/search_n.hpp b/include/range/v3/algorithm/search_n.hpp index 9fa827448a..c87eaaea86 100644 --- a/include/range/v3/algorithm/search_n.hpp +++ b/include/range/v3/algorithm/search_n.hpp @@ -170,7 +170,7 @@ namespace ranges /// \pre requires forward_range AND indirectly_comparable, V const *, C, P>) - safe_subrange_t RANGES_FUNC(search_n)(Rng && rng, + borrowed_subrange_t RANGES_FUNC(search_n)(Rng && rng, iter_difference_t> cnt, V const & val, C pred = C{}, diff --git a/include/range/v3/view/subrange.hpp b/include/range/v3/view/subrange.hpp index 79f096a05d..73829cfa2d 100644 --- a/include/range/v3/view/subrange.hpp +++ b/include/range/v3/view/subrange.hpp @@ -431,7 +431,11 @@ namespace ranges RANGES_INLINE_VARIABLE(make_subrange_fn, make_subrange) template - using safe_subrange_t = detail::maybe_dangling_>>; + using borrowed_subrange_t = detail::maybe_dangling_>>; + + template + using safe_subrange_t RANGES_DEPRECATED("Use borrowed_subrange_t instead.") = + borrowed_subrange_t; namespace cpp20 { @@ -447,7 +451,11 @@ namespace ranges (K == subrange_kind::sized || !sized_sentinel_for)) // using subrange = ranges::subrange; - using ranges::safe_subrange_t; + using ranges::borrowed_subrange_t; + + template + using safe_subrange_t RANGES_DEPRECATED("Use borrowed_subrange_t instead.") = + borrowed_subrange_t; } // namespace cpp20 /// @} } // namespace ranges diff --git a/test/view/subrange.cpp b/test/view/subrange.cpp index aced0f3464..26c157ae6b 100644 --- a/test/view/subrange.cpp +++ b/test/view/subrange.cpp @@ -21,7 +21,7 @@ CPP_template(class Rng)( requires ranges::range) -ranges::safe_subrange_t algorithm(Rng &&rng); +ranges::borrowed_subrange_t algorithm(Rng &&rng); struct Base {}; struct Derived : Base {}; @@ -33,7 +33,7 @@ int main() std::vector vi{1,2,3,4}; //////////////////////////////////////////////////////////////////////////// - // safe_subrange_t tests: + // borrowed_subrange_t tests: // lvalues are ReferenceableRanges and do not dangle: CPP_assert(same_as,