cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Backports related to Standard header <numeric>
(or automatically by including <cxxomfort/backports.hpp>
/ <cxxomfort/cxxomfort.hpp>
)
Interfaces defined in this section:
iota()
(C++11) - generate sequences of increasing values.gcd()
, lcm()
(C++17) - math functions for greatest common divisor.midpoint()
(C++20) - midpoint of integers, floating points or pointers.accumulate()
and inner_product()
with std::move()
versions as per C++20, under namespace cxxomfort::cxxostd::cxx20
.Implementation fixes:
Proposal p0616r0 introduces modifications to the algorithms under <numeric>
so that they invoke std::move()
on the accumulated cursor. The proposal indicates that this was first intended for C++11 but never proposed because of a lack of "bravery" as it was thought back then that this would introduce a breaking change.
Essentially, the new versions of these algorithms change the underlying operation loop as follows:
Because cxxomfort can not overwrite already existing functions, an opt-in shadowing mechanism is offered instead with the new functions being offered:
gcd - gcd/lcm functions (and templates for C++<11).
accumulate20 - move-capable versions of algorithms from C++20.