17#ifndef RANGES_V3_NUMERIC_ADJACENT_DIFFERENCE_HPP
18#define RANGES_V3_NUMERIC_ADJACENT_DIFFERENCE_HPP
22#include <range/v3/algorithm/result_types.hpp>
33#include <range/v3/utility/static_const.hpp>
35#include <range/v3/detail/prologue.hpp>
44 template(
typename I,
typename O,
typename BOp,
typename P)(
45 concept (differenceable_)(I, O, BOp, P),
46 invocable<P&, iter_value_t<I>> AND
47 copy_constructible<uncvref_t<invoke_result_t<P&, iter_value_t<I>>>> AND
48 movable<uncvref_t<invoke_result_t<P&, iter_value_t<I>>>> AND
49 output_iterator<O, invoke_result_t<P&, iter_value_t<I>>> AND
55 invoke_result_t<P&, iter_value_t<I>>> AND
60 invoke_result_t<P&, iter_value_t<I>>,
61 invoke_result_t<P&, iter_value_t<I>>>>);
65 template<
typename I,
typename O,
typename BOp = minus,
typename P =
identity>
66 CPP_concept differenceable =
71 template<
typename I,
typename O>
72 using adjacent_difference_result = detail::in_out_result<I, O>;
76 template(
typename I,
typename S,
typename O,
typename S2,
typename BOp =
minus,
80 adjacent_difference_result<I, O> operator()(I first,
88 using V = iter_value_t<I>;
89 using X = invoke_result_t<P &, V>;
93 if(first != last && result != end_result)
95 auto t1(x(invoke(proj, v(*first))));
97 for(++first, ++result; first != last && result != end_result;
100 auto t2(x(invoke(proj, v(*first))));
101 *result = invoke(bop, t2, t1);
105 return {first, result};
108 template(
typename I,
typename S,
typename O,
typename BOp =
minus,
111 adjacent_difference_result<I, O>
112 operator()(I first, S last, O result, BOp bop = BOp{}, P proj = P{})
const
114 return (*
this)(std::move(first),
122 template(
typename Rng,
typename ORef,
typename BOp =
minus,
typename P =
identity,
125 adjacent_difference_result<borrowed_iterator_t<Rng>, O>
126 operator()(Rng && rng, ORef && result, BOp bop = BOp{}, P proj = P{})
const
128 return (*
this)(begin(rng),
130 static_cast<ORef &&
>(result),
135 template(
typename Rng,
typename ORng,
typename BOp =
minus,
typename P =
identity,
138 adjacent_difference_result<borrowed_iterator_t<Rng>, borrowed_iterator_t<ORng>>
139 operator()(Rng && rng, ORng && result, BOp bop = BOp{}, P proj = P{})
const
141 return (*
this)(begin(rng),
154#include <range/v3/detail/epilogue.hpp>
The differenceable_ concept.
The differenceable concept.
The sentinel_for concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
Definition adjacent_difference.hpp:75
Definition arithmetic.hpp:78
Definition identity.hpp:25
Definition arithmetic.hpp:35