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)
97 for(++
first, ++result;
first != last && result != end_result;
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
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector > >, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition: meta.hpp:541
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
std::integral_constant< decltype(T::type::value - U::type::value), T::type::value - U::type::value > minus
An integral constant wrapper around the result of subtracting the two wrapped integers T::type::value...
Definition: meta.hpp:204
Definition: adjacent_difference.hpp:75
Definition: arithmetic.hpp:78
Definition: identity.hpp:25