|
cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Backports related to Standard header <algorithm>
Backports defined in this section:
Some C++98 algorithms that might be missing in older compilers, such as fill() .all_of() , any_of() , none_of() (C++11) - check if elements of a sequence fit a predicate.copy_if() , copy_n() , partition_copy() (C++11) - copy elements from a sequence.find_if_not() (C++11) - check if elements don't fit a predicate.is_permutation() , next_permutation(), prev_permutation() (C++11) - check the sorting status of a sequence.is_sorted() , is_sorted_until() (C++11) - check the sorting status of a sequence.minmax() , minmax_element() (C++11) - minimum and maximum elements in a sequence.equal() , mismatch() overloads (C++14) - compare sequences.clamp() (C++17) - constrain values.count() , count_if() (C++17) - count elements in a sequence.for_each_n() (C++17) - execute functors across a sequence.shift_left(), shift_right() (C++20) - slide a sequence.Ommitted:
Non-backport features ( "Implementation Fixes" and others ):
constexpr algorithms - see Constexpr-capable algorithmsStarting with C++20, a high number of features in <algorithm> are made constexpr capable.
This header offers a number of constexpr -capable implementations for some algorithms that can be made constexpr with only C++11 or C++14 requirement but weren't in their corresponding Standard. Because the names can not be reused by cxxomfort without UB as they might end up sharing the same number of arguments (see eg.: equal() / mismatch() in C++14) , they are instead provided via a new mechanism:
The functions are provided in namespace cxxomfort::fix and lead with a constexpr_tag argument. For example, the following invocations will call the constexpr-capable functions in cxxomfort:
These algorithms are:
cxxomfort::fix::clamp() cxxomfort::fix::count() cxxomfort::fix::count_if() cxxomfort::fix::find() cxxomfort::fix::find_if() cxxomfort::fix::equal() constexpr . Consult your compiler manual for more information.constexpr types whose iterators are pointer types (eg.: basic_string with default allocator).Copies and prints elements from a list via copy_if() and for_each_n() .
For other examples see the following entries in cxxomfort-examples :
randomly - usage of various algorithms.
1.8.13