Skip to content

Commit

Permalink
Merge pull request #1542 from ericniebler/borrowed_subrange_t
Browse files Browse the repository at this point in the history
Replace safe_subrange_t with borrowed_subrange_t
  • Loading branch information
ericniebler authored Aug 6, 2020
2 parents 65c6c48 + 3618ec4 commit 82843ae
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/range/v3/algorithm/equal_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace ranges
/// \pre
requires forward_range<Rng> AND
indirect_strict_weak_order<C, V const *, projected<iterator_t<Rng>, P>>)
safe_subrange_t<Rng> //
borrowed_subrange_t<Rng> //
RANGES_FUNC(equal_range)(Rng && rng, V const & val, C pred = C{}, P proj = P{}) //
{
if(RANGES_CONSTEXPR_IF(sized_range<Rng>))
Expand Down
2 changes: 1 addition & 1 deletion include/range/v3/algorithm/find_end.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace ranges
/// \pre
requires forward_range<Rng1> AND forward_range<Rng2> AND
indirect_relation<R, projected<iterator_t<Rng1>, P>, iterator_t<Rng2>>)
safe_subrange_t<Rng1> RANGES_FUNC(find_end)(
borrowed_subrange_t<Rng1> RANGES_FUNC(find_end)(
Rng1 && rng1, Rng2 && rng2, R pred = R{}, P proj = P{}) //
{
return (*this)(begin(rng1),
Expand Down
2 changes: 1 addition & 1 deletion include/range/v3/algorithm/rotate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace ranges
template(typename Rng, typename I = iterator_t<Rng>)(
/// \pre
requires range<Rng> AND permutable<I>)
safe_subrange_t<Rng> RANGES_FUNC(rotate)(Rng && rng, I middle) //
borrowed_subrange_t<Rng> RANGES_FUNC(rotate)(Rng && rng, I middle) //
{
return (*this)(begin(rng), std::move(middle), end(rng));
}
Expand Down
2 changes: 1 addition & 1 deletion include/range/v3/algorithm/search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ namespace ranges
/// \pre
requires forward_range<Rng1> AND forward_range<Rng2> AND
indirectly_comparable<iterator_t<Rng1>, iterator_t<Rng2>, C, P1, P2>)
safe_subrange_t<Rng1> RANGES_FUNC(search)(
borrowed_subrange_t<Rng1> RANGES_FUNC(search)(
Rng1 && rng1, Rng2 && rng2, C pred = C{}, P1 proj1 = P1{}, P2 proj2 = P2{}) //
{
if(empty(rng2))
Expand Down
2 changes: 1 addition & 1 deletion include/range/v3/algorithm/search_n.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace ranges
/// \pre
requires forward_range<Rng> AND
indirectly_comparable<iterator_t<Rng>, V const *, C, P>)
safe_subrange_t<Rng> RANGES_FUNC(search_n)(Rng && rng,
borrowed_subrange_t<Rng> RANGES_FUNC(search_n)(Rng && rng,
iter_difference_t<iterator_t<Rng>> cnt,
V const & val,
C pred = C{},
Expand Down
12 changes: 10 additions & 2 deletions include/range/v3/view/subrange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,11 @@ namespace ranges
RANGES_INLINE_VARIABLE(make_subrange_fn, make_subrange)

template<typename R>
using safe_subrange_t = detail::maybe_dangling_<R, subrange<iterator_t<R>>>;
using borrowed_subrange_t = detail::maybe_dangling_<R, subrange<iterator_t<R>>>;

template<typename R>
using safe_subrange_t RANGES_DEPRECATED("Use borrowed_subrange_t instead.") =
borrowed_subrange_t<R>;

namespace cpp20
{
Expand All @@ -447,7 +451,11 @@ namespace ranges
(K == subrange_kind::sized || !sized_sentinel_for<S, I>)) //
using subrange = ranges::subrange<I, S, K>;

using ranges::safe_subrange_t;
using ranges::borrowed_subrange_t;

template<typename R>
using safe_subrange_t RANGES_DEPRECATED("Use borrowed_subrange_t instead.") =
borrowed_subrange_t<R>;
} // namespace cpp20
/// @}
} // namespace ranges
Expand Down
4 changes: 2 additions & 2 deletions test/view/subrange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

CPP_template(class Rng)(
requires ranges::range<Rng>)
ranges::safe_subrange_t<Rng> algorithm(Rng &&rng);
ranges::borrowed_subrange_t<Rng> algorithm(Rng &&rng);

struct Base {};
struct Derived : Base {};
Expand All @@ -33,7 +33,7 @@ int main()
std::vector<int> vi{1,2,3,4};

////////////////////////////////////////////////////////////////////////////
// safe_subrange_t tests:
// borrowed_subrange_t tests:

// lvalues are ReferenceableRanges and do not dangle:
CPP_assert(same_as<subrange<int*>,
Expand Down

0 comments on commit 82843ae

Please sign in to comment.