init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
allhaileris
2026-02-16 15:50:16 +03:00
commit afb81b8278
13816 changed files with 3689732 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
/// \file
// Range v3 library
//
// Copyright Eric Niebler 2013-present
//
// Use, modification and distribution is subject to the
// Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef RANGES_V3_NUMERIC_ACCUMULATE_HPP
#define RANGES_V3_NUMERIC_ACCUMULATE_HPP
#include <meta/meta.hpp>
#include <range/v3/functional/arithmetic.hpp>
#include <range/v3/functional/identity.hpp>
#include <range/v3/functional/invoke.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/iterator/traits.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/traits.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/detail/prologue.hpp>
namespace ranges
{
/// \addtogroup group-numerics
/// @{
struct accumulate_fn
{
template(typename I, typename S, typename T, typename Op = plus,
typename P = identity)(
requires sentinel_for<S, I> AND input_iterator<I> AND
indirectly_binary_invocable_<Op, T *, projected<I, P>> AND
assignable_from<T &, indirect_result_t<Op &, T *, projected<I, P>>>)
T operator()(I first, S last, T init, Op op = Op{},
P proj = P{}) const
{
for(; first != last; ++first)
init = invoke(op, init, invoke(proj, *first));
return init;
}
template(typename Rng, typename T, typename Op = plus, typename P = identity)(
requires input_range<Rng> AND
indirectly_binary_invocable_<Op, T *, projected<iterator_t<Rng>, P>> AND
assignable_from<
T &, indirect_result_t<Op &, T *, projected<iterator_t<Rng>, P>>>)
T operator()(Rng && rng, T init, Op op = Op{}, P proj = P{}) const
{
return (*this)(
begin(rng), end(rng), std::move(init), std::move(op), std::move(proj));
}
};
RANGES_INLINE_VARIABLE(accumulate_fn, accumulate)
/// @}
} // namespace ranges
#include <range/v3/detail/epilogue.hpp>
#endif

View File

@@ -0,0 +1,156 @@
/// \file
// Range v3 library
//
// Copyright Eric Niebler 2004
// Copyright Gonzalo Brito Gadeschi 2014
//
// Use, modification and distribution is subject to the
// Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
// Implementation based on the code in libc++
// http://http://libcxx.llvm.org/
#ifndef RANGES_V3_NUMERIC_ADJACENT_DIFFERENCE_HPP
#define RANGES_V3_NUMERIC_ADJACENT_DIFFERENCE_HPP
#include <meta/meta.hpp>
#include <range/v3/algorithm/result_types.hpp>
#include <range/v3/functional/arithmetic.hpp>
#include <range/v3/functional/identity.hpp>
#include <range/v3/functional/invoke.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/iterator/traits.hpp>
#include <range/v3/iterator/unreachable_sentinel.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/dangling.hpp>
#include <range/v3/range/traits.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/detail/prologue.hpp>
namespace ranges
{
/// \addtogroup group-numerics
/// @{
// clang-format off
/// \concept differenceable_
/// \brief The \c differenceable_ concept
template(typename I, typename O, typename BOp, typename P)(
concept (differenceable_)(I, O, BOp, P),
invocable<P&, iter_value_t<I>> AND
copy_constructible<uncvref_t<invoke_result_t<P&, iter_value_t<I>>>> AND
movable<uncvref_t<invoke_result_t<P&, iter_value_t<I>>>> AND
output_iterator<O, invoke_result_t<P&, iter_value_t<I>>> AND
invocable<
BOp&,
invoke_result_t<
P&,
iter_value_t<I>>,
invoke_result_t<P&, iter_value_t<I>>> AND
output_iterator<
O,
invoke_result_t<
BOp&,
invoke_result_t<P&, iter_value_t<I>>,
invoke_result_t<P&, iter_value_t<I>>>>);
/// \concept differenceable
/// \brief The \c differenceable concept
template<typename I, typename O, typename BOp = minus, typename P = identity>
CPP_concept differenceable =
input_iterator<I> &&
CPP_concept_ref(ranges::differenceable_, I, O, BOp, P);
// clang-format on
template<typename I, typename O>
using adjacent_difference_result = detail::in_out_result<I, O>;
struct adjacent_difference_fn
{
template(typename I, typename S, typename O, typename S2, typename BOp = minus,
typename P = identity)(
requires sentinel_for<S, I> AND sentinel_for<S2, O> AND
differenceable<I, O, BOp, P>)
adjacent_difference_result<I, O> operator()(I first,
S last,
O result,
S2 end_result,
BOp bop = BOp{},
P proj = P{}) const
{
// BUGBUG think about the use of coerce here.
using V = iter_value_t<I>;
using X = invoke_result_t<P &, V>;
coerce<V> v;
coerce<X> x;
if(first != last && result != end_result)
{
auto t1(x(invoke(proj, v(*first))));
*result = t1;
for(++first, ++result; first != last && result != end_result;
++first, ++result)
{
auto t2(x(invoke(proj, v(*first))));
*result = invoke(bop, t2, t1);
t1 = std::move(t2);
}
}
return {first, result};
}
template(typename I, typename S, typename O, typename BOp = minus,
typename P = identity)(
requires sentinel_for<S, I> AND differenceable<I, O, BOp, P>)
adjacent_difference_result<I, O> //
operator()(I first, S last, O result, BOp bop = BOp{}, P proj = P{}) const
{
return (*this)(std::move(first),
std::move(last),
std::move(result),
unreachable,
std::move(bop),
std::move(proj));
}
template(typename Rng, typename ORef, typename BOp = minus, typename P = identity,
typename I = iterator_t<Rng>, typename O = uncvref_t<ORef>)(
requires range<Rng> AND differenceable<I, O, BOp, P>)
adjacent_difference_result<borrowed_iterator_t<Rng>, O> //
operator()(Rng && rng, ORef && result, BOp bop = BOp{}, P proj = P{}) const
{
return (*this)(begin(rng),
end(rng),
static_cast<ORef &&>(result),
std::move(bop),
std::move(proj));
}
template(typename Rng, typename ORng, typename BOp = minus, typename P = identity,
typename I = iterator_t<Rng>, typename O = iterator_t<ORng>)(
requires range<Rng> AND range<ORng> AND differenceable<I, O, BOp, P>)
adjacent_difference_result<borrowed_iterator_t<Rng>, borrowed_iterator_t<ORng>>
operator()(Rng && rng, ORng && result, BOp bop = BOp{}, P proj = P{}) const
{
return (*this)(begin(rng),
end(rng),
begin(result),
end(result),
std::move(bop),
std::move(proj));
}
};
RANGES_INLINE_VARIABLE(adjacent_difference_fn, adjacent_difference)
/// @}
} // namespace ranges
#include <range/v3/detail/epilogue.hpp>
#endif

View File

@@ -0,0 +1,160 @@
/// \file
// Range v3 library
//
// Copyright Eric Niebler 2013-present
// Copyright Gonzalo Brito Gadeschi 2014
//
// Use, modification and distribution is subject to the
// Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef RANGES_V3_NUMERIC_INNER_PRODUCT_HPP
#define RANGES_V3_NUMERIC_INNER_PRODUCT_HPP
#include <meta/meta.hpp>
#include <range/v3/functional/arithmetic.hpp>
#include <range/v3/functional/concepts.hpp>
#include <range/v3/functional/identity.hpp>
#include <range/v3/functional/invoke.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/iterator/traits.hpp>
#include <range/v3/iterator/unreachable_sentinel.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/traits.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/detail/prologue.hpp>
namespace ranges
{
/// \addtogroup group-numerics
/// @{
// clang-format off
/// \concept inner_product_constraints_
/// \brief The \c inner_product_constraints_ concept
template(typename I1, typename I2, typename T, typename BOp1, typename BOp2,
typename P1, typename P2)(
concept (inner_product_constraints_)(I1, I2, T, BOp1, BOp2, P1, P2),
invocable<P1&, iter_value_t<I1>> AND
invocable<P2&, iter_value_t<I2>> AND
invocable<
BOp2&,
invoke_result_t<P1&, iter_value_t<I1>>,
invoke_result_t<P2&, iter_value_t<I2>>> AND
invocable<
BOp1&,
T,
invoke_result_t<
BOp2&,
invoke_result_t<P1&, iter_value_t<I1>>,
invoke_result_t<P2&, iter_value_t<I2>>>> AND
assignable_from<
T&,
invoke_result_t<
BOp1&,
T,
invoke_result_t<
BOp2&,
invoke_result_t<P1&, iter_value_t<I1>>,
invoke_result_t<P2&, iter_value_t<I2>>>>>
);
/// \concept inner_product_constraints
/// \brief The \c inner_product_constraints concept
template<typename I1, typename I2, typename T, typename BOp1 = plus,
typename BOp2 = multiplies, typename P1 = identity, typename P2 = identity>
CPP_concept inner_product_constraints =
input_iterator<I1> &&
input_iterator<I2> &&
CPP_concept_ref(ranges::inner_product_constraints_, I1, I2, T, BOp1, BOp2, P1, P2);
// clang-format on
struct inner_product_fn
{
template(typename I1, typename S1, typename I2, typename S2, typename T,
typename BOp1 = plus, typename BOp2 = multiplies, typename P1 = identity,
typename P2 = identity)(
requires sentinel_for<S1, I1> AND sentinel_for<S2, I2> AND
inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>)
T operator()(I1 begin1, S1 end1, I2 begin2, S2 end2, T init,
BOp1 bop1 = BOp1{}, BOp2 bop2 = BOp2{}, P1 proj1 = P1{},
P2 proj2 = P2{}) const
{
for(; begin1 != end1 && begin2 != end2; ++begin1, ++begin2)
init =
invoke(bop1,
init,
invoke(bop2, invoke(proj1, *begin1), invoke(proj2, *begin2)));
return init;
}
template(typename I1, typename S1, typename I2, typename T, typename BOp1 = plus,
typename BOp2 = multiplies, typename P1 = identity,
typename P2 = identity)(
requires sentinel_for<S1, I1> AND
inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>)
T operator()(I1 begin1, S1 end1, I2 begin2, T init, BOp1 bop1 = BOp1{},
BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const
{
return (*this)(std::move(begin1),
std::move(end1),
std::move(begin2),
unreachable,
std::move(init),
std::move(bop1),
std::move(bop2),
std::move(proj1),
std::move(proj2));
}
template(typename Rng1, typename I2Ref, typename T, typename BOp1 = plus,
typename BOp2 = multiplies, typename P1 = identity,
typename P2 = identity, typename I1 = iterator_t<Rng1>,
typename I2 = uncvref_t<I2Ref>)(
requires range<Rng1> AND
inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>)
T operator()(Rng1 && rng1, I2Ref && begin2, T init, BOp1 bop1 = BOp1{},
BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const
{
return (*this)(begin(rng1),
end(rng1),
static_cast<I2Ref &&>(begin2),
std::move(init),
std::move(bop1),
std::move(bop2),
std::move(proj1),
std::move(proj2));
}
template(typename Rng1, typename Rng2, typename T, typename BOp1 = plus,
typename BOp2 = multiplies, typename P1 = identity,
typename P2 = identity, typename I1 = iterator_t<Rng1>,
typename I2 = iterator_t<Rng2>)(
requires range<Rng1> AND range<Rng2> AND
inner_product_constraints<I1, I2, T, BOp1, BOp2, P1, P2>)
T operator()(Rng1 && rng1, Rng2 && rng2, T init, BOp1 bop1 = BOp1{},
BOp2 bop2 = BOp2{}, P1 proj1 = P1{}, P2 proj2 = P2{}) const
{
return (*this)(begin(rng1),
end(rng1),
begin(rng2),
end(rng2),
std::move(init),
std::move(bop1),
std::move(bop2),
std::move(proj1),
std::move(proj2));
}
};
RANGES_INLINE_VARIABLE(inner_product_fn, inner_product)
/// @}
} // namespace ranges
#include <range/v3/detail/epilogue.hpp>
#endif

View File

@@ -0,0 +1,55 @@
/// \file
// Range v3 library
//
// Copyright Eric Niebler 2013-present
//
// Use, modification and distribution is subject to the
// Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef RANGES_V3_NUMERIC_IOTA_HPP
#define RANGES_V3_NUMERIC_IOTA_HPP
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/dangling.hpp>
#include <range/v3/range/traits.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/detail/prologue.hpp>
namespace ranges
{
/// \addtogroup group-numerics
/// @{
struct iota_fn
{
template(typename O, typename S, typename T)(
requires output_iterator<O, T const &> AND sentinel_for<S, O> AND
weakly_incrementable<T>)
O operator()(O first, S last, T val) const
{
for(; first != last; ++first, ++val)
*first = detail::as_const(val);
return first;
}
template(typename Rng, typename T)(
requires output_range<Rng, T const &> AND weakly_incrementable<T>)
borrowed_iterator_t<Rng> operator()(Rng && rng, T val) const //
{
return (*this)(begin(rng), end(rng), detail::move(val));
}
};
RANGES_INLINE_VARIABLE(iota_fn, iota)
/// @}
} // namespace ranges
#include <range/v3/detail/epilogue.hpp>
#endif

View File

@@ -0,0 +1,178 @@
/// \file
// Range v3 library
//
// Copyright Eric Niebler 2013-present
// Copyright Gonzalo Brito Gadeschi 2014
//
// Use, modification and distribution is subject to the
// Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef RANGES_V3_NUMERIC_PARTIAL_SUM_HPP
#define RANGES_V3_NUMERIC_PARTIAL_SUM_HPP
#include <meta/meta.hpp>
#include <range/v3/algorithm/result_types.hpp>
#include <range/v3/functional/arithmetic.hpp>
#include <range/v3/functional/compose.hpp>
#include <range/v3/functional/identity.hpp>
#include <range/v3/functional/invoke.hpp>
#include <range/v3/iterator/concepts.hpp>
#include <range/v3/iterator/traits.hpp>
#include <range/v3/iterator/unreachable_sentinel.hpp>
#include <range/v3/range/access.hpp>
#include <range/v3/range/concepts.hpp>
#include <range/v3/range/dangling.hpp>
#include <range/v3/range/traits.hpp>
#include <range/v3/utility/static_const.hpp>
#include <range/v3/detail/prologue.hpp>
namespace ranges
{
/// \addtogroup group-numerics
/// @{
/// \cond
namespace detail
{
// Only needed for type-checking purposes:
struct as_lvalue_fn
{
template<typename T>
constexpr T & operator()(T && t) const noexcept
{
return t;
}
};
template<typename I>
using as_value_type_t = composed<as_lvalue_fn, coerce<iter_value_t<I>>>;
} // namespace detail
/// \endcond
// axiom: BOp is associative over values of I.
// clang-format off
/// \concept indirect_semigroup_
/// \brief The \c indirect_semigroup_ concept
template(typename I, typename BOp)(
concept (indirect_semigroup_)(I, BOp),
copyable<iter_value_t<I>> AND
indirectly_regular_binary_invocable_<
composed<coerce<iter_value_t<I>>, BOp>,
iter_value_t<I>*, I>
);
/// \concept indirect_semigroup
/// \brief The \c indirect_semigroup concept
template<typename I, typename BOp>
CPP_concept indirect_semigroup =
indirectly_readable<I> &&
CPP_concept_ref(ranges::indirect_semigroup_, I, BOp);
/// \concept partial_sum_constraints_
/// \brief The \c partial_sum_constraints_ concept
template(typename I, typename O, typename BOp, typename P)(
concept (partial_sum_constraints_)(I, O, BOp, P),
indirect_semigroup<
projected<projected<I, detail::as_value_type_t<I>>, P>,
BOp> AND
output_iterator<
O,
iter_value_t<
projected<projected<I, detail::as_value_type_t<I>>, P>> const &>
);
/// \concept partial_sum_constraints
/// \brief The \c partial_sum_constraints concept
template<typename I, typename O, typename BOp = plus, typename P = identity>
CPP_concept partial_sum_constraints =
input_iterator<I> &&
CPP_concept_ref(ranges::partial_sum_constraints_, I, O, BOp, P);
// clang-format on
template<typename I, typename O>
using partial_sum_result = detail::in_out_result<I, O>;
struct partial_sum_fn
{
template(typename I, typename S1, typename O, typename S2, typename BOp = plus,
typename P = identity)(
requires sentinel_for<S1, I> AND sentinel_for<S2, O> AND
partial_sum_constraints<I, O, BOp, P>)
partial_sum_result<I, O> operator()(I first,
S1 last,
O result,
S2 end_result,
BOp bop = BOp{},
P proj = P{}) const
{
using X = projected<projected<I, detail::as_value_type_t<I>>, P>;
coerce<iter_value_t<I>> val_i;
coerce<iter_value_t<X>> val_x;
if(first != last && result != end_result)
{
auto && cur1 = val_i(*first);
iter_value_t<X> t(invoke(proj, cur1));
*result = t;
for(++first, ++result; first != last && result != end_result;
++first, ++result)
{
auto && cur2 = val_i(*first);
t = val_x(invoke(bop, t, invoke(proj, cur2)));
*result = t;
}
}
return {first, result};
}
template(typename I, typename S, typename O, typename BOp = plus,
typename P = identity)(
requires sentinel_for<S, I> AND partial_sum_constraints<I, O, BOp, P>)
partial_sum_result<I, O> //
operator()(I first, S last, O result, BOp bop = BOp{}, P proj = P{}) const
{
return (*this)(std::move(first),
std::move(last),
std::move(result),
unreachable,
std::move(bop),
std::move(proj));
}
template(typename Rng, typename ORef, typename BOp = plus, typename P = identity,
typename I = iterator_t<Rng>, typename O = uncvref_t<ORef>)(
requires range<Rng> AND partial_sum_constraints<I, O, BOp, P>)
partial_sum_result<borrowed_iterator_t<Rng>, O> //
operator()(Rng && rng, ORef && result, BOp bop = BOp{}, P proj = P{}) const
{
return (*this)(begin(rng),
end(rng),
static_cast<ORef &&>(result),
std::move(bop),
std::move(proj));
}
template(typename Rng, typename ORng, typename BOp = plus, typename P = identity,
typename I = iterator_t<Rng>, typename O = iterator_t<ORng>)(
requires range<Rng> AND range<ORng> AND partial_sum_constraints<I, O, BOp, P>)
partial_sum_result<borrowed_iterator_t<Rng>, borrowed_iterator_t<ORng>> //
operator()(Rng && rng, ORng && result, BOp bop = BOp{}, P proj = P{}) const
{
return (*this)(begin(rng),
end(rng),
begin(result),
end(result),
std::move(bop),
std::move(proj));
}
};
RANGES_INLINE_VARIABLE(partial_sum_fn, partial_sum)
/// @}
} // namespace ranges
#include <range/v3/detail/epilogue.hpp>
#endif