cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Backports made available by cxxomfort. More...
Classes | |
struct | array |
C++11 array class. More... | |
class | basic_string_view |
Read-only view of a string or string-like object, from C++17. See also string/basic_string_view @ cppreference . More... | |
class | bool_constant |
A bool compile time equivalent of integral_constant , as per C++17. More... | |
struct | byte |
Implements the backport for std::byte . More... | |
struct | default_delete |
struct | index_sequence |
Integer sequence of size_t . More... | |
struct | integer_sequence |
C++14 integer_sequence utility. More... | |
struct | is_invocable |
Trait that describes if a functor of type F is invocable. More... | |
struct | linear_congruential_engine |
Backports std::linear_congruential_engine to compilers that miss it or use a different name. More... | |
struct | make_index_sequence |
struct | make_integer_sequence |
struct | make_void |
Metaprogramming helper that exposes void as a type, for transformations. More... | |
struct | pointer_traits |
API to refer to properties of pointer types. More... | |
struct | reference_wrapper |
std::reference_wrapper<T> implementation More... | |
struct | subtract_with_carry_engine |
Backports std::subtract_with_carry_engine to compilers that miss it or use a different name. More... | |
struct | timespec |
Struct timespec, from POSIX / C++17. Basically it stores a time_t value plus an offset in nanoseconds, where available. More... | |
class | tuple |
std::tuple<T...> implementation More... | |
class | type_index |
class | unique_ptr |
unique_ptr: a scoped, movable smart pointer. More... | |
Typedefs | |
typedef basic_string_view< char, std::char_traits< char > > | string_view |
Name for a strng view of char . | |
typedef basic_string_view< wchar_t, std::char_traits< wchar_t > > | wstring_view |
Name for a string view of wchar_t . | |
typedef std::ranlux24_base | default_random_engine |
cxxomfort uses ranlux24_base as its "default random engine". More... | |
Functions | |
template<typename It , typename T > | |
CXXO_CONSTEXPR14 void | fill (It ini, It fin, T const &tv) |
Fills a sequence with a given value. More... | |
template<typename It , typename Numeric , typename T > | |
CXXO_CONSTEXPR14 void | fill_n (It ini, Numeric n, T const &tv) |
Fills a sequence with a given value. More... | |
template<typename InpI , typename OutI , typename Predicate > | |
OutI | copy_if (InpI ini, InpI fin, OutI dest, Predicate f) |
Copy elements conditionally to dest if they fulfill f .Copy elements from one sequence to another. More... | |
template<typename InpI , typename Integral , typename OutI > | |
OutI | copy_n (InpI ini, Integral n, OutI dest) |
Copy a given amount of elements to dest . More... | |
template<typename InpI , typename OutI1 , typename OutI2 , typename Predicate > | |
std::pair< OutI1, OutI2 > | partition_copy (InpI ini, InpI const fin, OutI1 Dtrue, OutI2 Dfalse, Predicate f) |
Conditionally copy from sequence [ini,fin) to either sequence starting at Dtrue or Dfalsef . More... | |
template<class It , class Pred > | |
CXXO_CONSTEXPR14 It | find_if (It ini, It fin, Pred f) |
Finds an element in a sequence that matches a predicate. More... | |
template<class It , class Pred > | |
CXXO_CONSTEXPR14 It | find_if_not (It ini, It fin, Pred f) |
Finds like find_if but the predicate is reversed. More... | |
template<class It , class Pred > | |
CXXO_CONSTEXPR14 std::iterator_traits< It >::difference_type | count_if (It ini, It fin, Pred p) |
Counts the number of times in a sequence the criteria p is matched. More... | |
template<class It , typename T > | |
CXXO_CONSTEXPR14 std::iterator_traits< It >::difference_type | count (It ini, It fin, T const &tv) |
Counts the number of times in a sequence a given value is found. More... | |
template<class RAIterator , class URNG > | |
void | shuffle (RAIterator ini, RAIterator fin, URNG &g) |
Shuffles a sequence according to a generator call g(). More... | |
template<typename Iterator , typename Compare > | |
bool | is_sorted (Iterator ini, Iterator fin, Compare less) |
Determines if a sequence is sorted according to a given criteria. More... | |
template<typename Iterator > | |
bool | is_sorted (Iterator ini, Iterator fin) |
template<class II , class Size , class UnaryFunction > | |
II | for_each_n (II first, Size n, UnaryFunction f) |
Executes a function once for each element in a sequence, using it as an argument. More... | |
template<typename T , size_t N> | |
constexpr auto | to_array (T(&arr)[N]) -> std::array< typename std::remove_cv< T >::type, N > |
Creates a std::array from a native C array. More... | |
template<typename T > | |
reference_wrapper< T > | ref (T &t) CXXO_NOEXCEPTNOTHROW |
Wraps an object in a reference_wrapper . More... | |
template<typename T > | |
reference_wrapper< T const > | cref (T const &t) CXXO_NOEXCEPTNOTHROW |
Wraps an object in a reference_wrapper to const . More... | |
template<typename T > | |
T * | addressof (T &arg) |
Returns the address of an object. More... | |
template<typename It1 , typename ItA > | |
bool | is_permutation (It1 ini1, It1 fin1, ItA iniA) |
Returns true if range [iniA,finA] (with internally calculated finA) is a permutation of range [ini1,fin1). More... | |
template<typename BidirIt , typename Compare > | |
bool | next_permutation (BidirIt ini, BidirIt fin, Compare Less) |
template<typename BidirIt , typename Compare > | |
bool | prev_permutation (BidirIt ini, BidirIt fin, Compare less) |
template<typename NativeType > | |
std::string | to_string (NativeType) |
Converts an integral variable into a std::string . More... | |
template<typename RangeIt1 , typename RangeIt2 , typename Compare > | |
bool | equal (RangeIt1 ini1, RangeIt1 fin1, RangeIt2 ini2, RangeIt2 fin2, Compare eq) |
Compare two sequences [ini1,fin1) and [ini2,fin2) for equality given comparator eq . Four-iterators overload. More... | |
template<typename RangeIt1 , typename RangeIt2 > | |
bool | equal (RangeIt1 ini1, RangeIt1 fin1, RangeIt2 ini2, RangeIt2 fin2) |
template<class InputIt1 , class InputIt2 , class BinaryPredicate > | |
std::pair< InputIt1, InputIt2 > | mismatch (InputIt1 ini1, InputIt1 fin1, InputIt2 ini2, InputIt2 fin2, BinaryPredicate p) |
Finds the first difference (dif1,dif2) between two sequences [ini1,fin1) and [ini2,fin2), given comparator eq . Four-iterator overload. More... | |
template<class InputIt1 , class InputIt2 > | |
std::pair< InputIt1, InputIt2 > | mismatch (InputIt1 ini1, InputIt1 fin1, InputIt2 ini2, InputIt2 fin2) |
template<typename T , typename ... Args> | |
std::unique_ptr< T > | make_unique (Args &&... args) |
Creates a unique_ptr holding a constructed object. More... | |
template<typename T , typename... TupleArgs> | |
T & | get (std::tuple< TupleArgs... > &) |
Return a member of a tuple given its type as a template argument. More... | |
template<typename T , typename... TupleArgs> | |
T const & | get (std::tuple< TupleArgs... > const &) |
template<typename T > | |
constexpr std::add_const< T >::type & | as_const (T &t) noexcept |
returns a const view of object t . A C++17 Backports . More... | |
template<typename T > | |
constexpr std::add_const< T >::type * | as_ptr_const (T *const t) noexcept |
returns a const view of a pointer t . An extension to as_const() . More... | |
bool | operator== (byte, byte) |
Compares the numerical expression of two bytes. | |
bool | operator!= (byte, byte) |
Compares the numerical expression of two bytes. | |
template<typename Integral > | |
Integral | to_integer (byte b) |
Converts the byte value into an Integral . More... | |
unsigned char | to_value (byte b) |
Converts the byte value into an unsigned char . | |
template<class T , class Compare > | |
constexpr T const & | clamp (T const &val, T const &lo, T const &hi, Compare comp) |
Clamps a value. More... | |
template<class T > | |
CXXO_CONSTEXPR T const & | clamp (T const &val, T const &lo, T const &hi) |
template<typename F , typename... Args> | |
dependent_type_t | invoke (F &&callable, Args &&... args) |
Invokes a callable. See also invoke_r() . More... | |
template<typename R , typename F , typename... Args> | |
R | invoke_r (F &&callable, Args &&... args) |
Invokes a callable and specifies a return type. See also invoke() . More... | |
template<typename C > | |
C::size_type | size (C &c) |
Returns the size (number of elements) of a sequence / container expression. More... | |
template<typename C > | |
constexpr auto | data (C &container) -> decltype(container.data()) |
provides access to an internal "<code>.data()</code>" member. More... | |
template<typename C > | |
bool | data (C const &container) |
provides access to an internal "<code>.empty()</code>" member. More... | |
template<typename C > | |
bool | empty (C const &c) |
Accesses and returns the .empty() member of the container. More... | |
template<typename C > | |
size_t | size (C const &c) |
Accesses and returns the .size() member of the container. More... | |
template<typename C > | |
C::pointer | data (C const &c) |
Accesses and returns the .data() member of the container. More... | |
template<typename T , typename... TupleArgs> | |
T | make_from_tuple (std::tuple< TupleArgs... > &&Tuple) |
Create an object from a tuple expression. More... | |
template<typename F , typename Tuple > | |
implementation_defined_t | apply (F f, Tuple &t) |
Applies the tuple t as the arguments to the functionlike / callable f . More... | |
template<typename Fn , typename... Binds> | |
implementation_defined_t | bind_front (Fn &&callable, Binds &&... args) |
Wraps a function and its first n arguments in a callable object. More... | |
template<typename T , typename U = T> | |
T | exchange (T &obj, CXXO_RV_REF(U) nval) |
Replaces a variable's value, returns the old value. More... | |
template<typename Fn > | |
not_fn_t< Fn > | not_fn (Fn &&f) |
Creates a function wrapper that returns the negation of a given function-like / callable. More... | |
template<typename Char > | |
implementation_defined_t | quoted (Char const *str, Char delim='\"', Char escape='\) |
Outputs a string to a stream, quoted. More... | |
template<typename Char > | |
implementation_defined_t | quoted (std::basic_string_view< Char > str, Char delim='\"', Char escape='\) |
template<typename It > | |
CXXO_CONSTEXPR14 std::reverse_iterator< It > | make_reverse_iterator (It i) |
Constructs the reverse_iterator for a given iterator. More... | |
template<typename FwIt , typename T > | |
FwIt | iota (FwIt ini, FwIt fin, T i0) |
Fills a sequence with a sequentially growing set of values. "Numeric" iota. More... | |
template<typename FwIt , typename Integer , typename T > | |
FwIt | iota_n (FwIt ini, Integer n, T i0) |
Fills a sequence with a sequentially growing set of values. More... | |
template<typename Num1 , typename Num2 > | |
CXXO_CONSTEXPR Num1 | gcd (Num1 n1, Num2 n2) CXXO_NOEXCEPT |
Calculates the greatest common divisor. More... | |
template<typename Num1 , typename Num2 > | |
CXXO_CONSTEXPR Num1 | lcm (Num1 n1, Num2 n2) CXXO_NOEXCEPT |
Calculates the lowest common multiple. More... | |
template<typename Numeric > | |
CXXO_CONSTEXPR Numeric | midpoint (Numeric n1, Numeric n2) CXXO_NOEXCEPTNOTHROW |
Returns the midpoint between two numeric values, avoiding overflows. More... | |
template<typename Pointer > | |
Pointer | midpoint (Pointer p1, Pointer p2) CXXO_NOEXCEPTNOTHROW |
Returns the midpoint between two pointers. More... | |
template<typename T > | |
T & | declval () |
Expression for an unevaluated context. "Type Utilities" declval. More... | |
template<typename U > | |
constexpr U | bit_width (U u) noexcept |
template<typename U > | |
constexpr U | bit_floor (U u) noexcept |
template<typename U > | |
constexpr U | bit_ceil (U u) noexcept |
template<typename U > | |
constexpr int | popcount (U u) noexcept |
int | timespec_get (struct timespec *ts, int base) |
Returns timespec information from the system clock and writes it into ts . More... | |
template<size_t I, typename T , size_t N> | |
CXXO_CONSTEXPR14 T & | get (array< T, N > &a) CXXO_NOEXCEPTNOTHROW |
Tuple-like interface to access an element in an array . More... | |
template<size_t I, typename T , size_t N> | |
CXXO_CONSTEXPR14 T const & | get (array< T, N > const &a) CXXO_NOEXCEPTNOTHROW |
template<typename Iter , typename Predicate > | |
bool | all_of (Iter ini, Iter fin, Predicate f) |
Checks if all elements of a sequence fit a given predicate. More... | |
template<typename Iter , typename Predicate > | |
bool | any_of (Iter ini, Iter fin, Predicate f) |
Checks if any one element of a sequence fit a given predicate. More... | |
template<typename Iter , typename Predicate > | |
bool | none_of (Iter ini, Iter fin, Predicate f) |
Checks if no elements of a sequence fit a given predicate. More... | |
template<typename T , typename Comparator > | |
std::pair< T const &, T const & > | minmax (T const &a, T const &b, Comparator Less) |
Return a pair(min,max) from two arguments and a comparator Less . More... | |
template<typename T > | |
std::pair< T const &, T const & > | minmax (T const &a, T const &b) |
template<typename FIterator , typename Comparator > | |
std::pair< FIterator, FIterator > | minmax_element (FIterator ini, FIterator fin, Comparator less) |
Returns the pair (minimum,maximum) for the given sequence and comparator less . More... | |
template<typename FIterator > | |
std::pair< FIterator, FIterator > | minmax_element (FIterator ini, FIterator fin) |
template<typename T > | |
void | destroy_at (T *p) CXXO_NOEXCEPTNOTHROW |
Destructs an object, as if the destructor was invoked via Type::~Type() . More... | |
template<typename Iter , typename Iter2 > | |
void | destroy (Iter ini, Iter2 fin) |
Destructs a sequence of objects. More... | |
template<typename Iter , typename Integer > | |
void | destroy_n (Iter ini, Integer n) |
Destructs a sequence of objects. More... | |
template<typename It > | |
void | uninitialized_default_construct (It ini, It fin) |
Default-constructs objects in uninitialized memory. More... | |
template<typename It , typename Integer > | |
void | uninitialized_default_construct_n (It ini, Integer n) |
Default-constructs objects in uninitialized memory. More... | |
Backports made available by cxxomfort.
Namespace that holds the library's backports of named C++ features.
struct cxxomfort::cxxostd::default_delete |
default_delete
(stateless deleter for default new
allocations ) Default deleter for utilities like unique_ptr
.
struct cxxomfort::cxxostd::is_invocable |
Trait that describes if a functor of type F is invocable.
struct cxxomfort::cxxostd::linear_congruential_engine |
Backports std::linear_congruential_engine
to compilers that miss it or use a different name.
<random>
backports. <random>
backports.struct cxxomfort::cxxostd::make_index_sequence |
Helper for index_sequence
struct cxxomfort::cxxostd::make_integer_sequence |
Helper for integer_sequence
struct cxxomfort::cxxostd::make_void |
Metaprogramming helper that exposes void
as a type, for transformations.
void
from an instantiation. struct cxxomfort::cxxostd::pointer_traits |
API to refer to properties of pointer types.
struct cxxomfort::cxxostd::subtract_with_carry_engine |
Backports std::subtract_with_carry_engine
to compilers that miss it or use a different name.
<random>
backports. <random>
backports.struct cxxomfort::cxxostd::timespec |
Struct timespec, from POSIX / C++17. Basically it stores a time_t
value plus an offset in nanoseconds, where available.
cxxomfort uses ranlux24_base
as its "default random engine".
ranlux24_base
as the default PRNG in cxxomfort. CXXO_CONSTEXPR14 void cxxomfort::cxxostd::fill | ( | It | ini, |
It | fin, | ||
T const & | tv | ||
) |
Fills a sequence with a given value.
tv | The value to use to fill. |
CXXO_CONSTEXPR14 void cxxomfort::cxxostd::fill_n | ( | It | ini, |
Numeric | n, | ||
T const & | tv | ||
) |
Fills a sequence with a given value.
n | How many elements to fill. |
tv | The value to use to fill. |
OutI cxxomfort::cxxostd::copy_if | ( | InpI | ini, |
InpI | fin, | ||
OutI | dest, | ||
Predicate | f | ||
) |
Copy elements conditionally to dest if they fulfill f .Copy elements from one sequence to another.
f | A predicate that will evaluate elements in the sequence. |
Given the sequence [ini, fin)
, copies those elements e inside it to dest for which the evlauation f(e)
is true
.
|
inline |
Copy a given amount of elements to dest .
Copies n elements from ini to , unconditionally.
Referenced by array_ref< CharTy const >::back(), and cxxomfort::library::algorithm::copy_leftmost_n().
std::pair<OutI1,OutI2> cxxomfort::cxxostd::partition_copy | ( | InpI | ini, |
InpI const | fin, | ||
OutI1 | Dtrue, | ||
OutI2 | Dfalse, | ||
Predicate | f | ||
) |
Conditionally copy from sequence [ini,fin) to either sequence starting at Dtrue
or Dfalsef
.
f | A predicate that maps InpI::value_type -> bool . |
std::pair
(Dtrue , Dfalse ).This algorithm is a variation of copy_if()
. Where copy_if copies to one destination dest if the condition is true
, partition_copy()
copies elements e in [ini,fin)
to either Dtrue or Dfalse depending on the return value of f(e)
.
CXXO_CONSTEXPR14 It cxxomfort::cxxostd::find_if | ( | It | ini, |
It | fin, | ||
Pred | f | ||
) |
Finds an element in a sequence that matches a predicate.
f | A predicate that maps It::value_type -> bool . |
constexpr
starting C++20; here it is tentatively marked constexpr
for C++14 as well. We can't modify the C++17 version. Referenced by cxxomfort::library::algorithm::find(), cxxomfort::fix::find_if(), and cxxomfort::library::algorithm::find_if_not().
CXXO_CONSTEXPR14 It cxxomfort::cxxostd::find_if_not | ( | It | ini, |
It | fin, | ||
Pred | f | ||
) |
Finds like find_if
but the predicate is reversed.
f | A predicate that maps It::value_type -> bool . |
constexpr
starting C++20; here it is tentatively marked constexpr
for C++14 as well. We can't modify the C++17 version. CXXO_CONSTEXPR14 std::iterator_traits<It>::difference_type cxxomfort::cxxostd::count_if | ( | It | ini, |
It | fin, | ||
Pred | p | ||
) |
Counts the number of times in a sequence the criteria p is matched.
f | A predicate that maps It::value_type -> bool . |
constexpr
starting C++20; here it is tentatively marked constexpr
for C++14 as well. We can't modify the C++17 version. Referenced by cxxomfort::fix::count_if().
CXXO_CONSTEXPR14 std::iterator_traits<It>::difference_type cxxomfort::cxxostd::count | ( | It | ini, |
It | fin, | ||
T const & | tv | ||
) |
Counts the number of times in a sequence a given value is found.
constexpr
starting C++20; here it is tentatively markes constexpr
for C++14 as well. We can't modify the C++17 version. Referenced by array_ref< CharTy const >::back(), cxxomfort::string::compare(), cxxomfort::fix::count_if(), is_permutation(), and array_ref< CharTy const >::rightmost().
void cxxomfort::cxxostd::shuffle | ( | RAIterator | ini, |
RAIterator | fin, | ||
URNG & | g | ||
) |
Shuffles a sequence according to a generator call g().
g | A writable object that acts like a (P)RNG and returns a value via operator() . |
|
inline |
Determines if a sequence is sorted according to a given criteria.
less | Criteria for sorting, a binary function f(x,y) that returns true if x<y . |
Referenced by is_sorted().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
II cxxomfort::cxxostd::for_each_n | ( | II | first, |
Size | n, | ||
UnaryFunction | f | ||
) |
Executes a function once for each element in a sequence, using it as an argument.
f | A function that takes arguments and can modify them. |
f | A function object that is executed as f(i) for each i in the sequence. |
accumulate()
. constexpr auto cxxomfort::cxxostd::to_array | ( | T(&) | arr[N] | ) | -> std::array< typename std::remove_cv< T >::type, N > |
Creates a std::array
from a native C array.
std::array
from a native C array. std::array
from a native C array.make_array()
or make_cxxo_array()
.
|
noexcept |
Returns the number of bits required to represent the value of u .
std::is_unsigned<U>::value
|
noexcept |
Returns u rounded down to a power of 2.
std::is_unsigned<U>::value
|
noexcept |
Returns u rounded up to a power of 2.
std::is_unsigned<U>::value
|
noexcept |
Returns the number of 1
bits in u .
std::is_unsigned<U>::value
int cxxomfort::cxxostd::timespec_get | ( | struct timespec * | ts, |
int | base | ||
) |
Returns timespec information from the system clock and writes it into ts .
timespec_get()
. CXXO_CONSTEXPR14 T& cxxomfort::cxxostd::get | ( | array< T, N > & | a | ) |
Tuple-like interface to access an element in an array
.
I | Index to be accessed. |
CXXO_CONSTEXPR14 T const& cxxomfort::cxxostd::get | ( | array< T, N > const & | a | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
reference_wrapper<T> cxxomfort::cxxostd::ref | ( | T & | t | ) |
Wraps an object in a reference_wrapper
.
reference_wrapper<T>
holding the named object t . reference_wrapper
reference_wrapper<T const> cxxomfort::cxxostd::cref | ( | T const & | t | ) |
Wraps an object in a reference_wrapper
to const
.
reference_wrapper<T const>
holding the named object t . reference_wrapper
|
inline |
Returns the address of an object.
&
unary. memory/addressof @ cppreference Referenced by destroy(), and destroy_n().
bool cxxomfort::cxxostd::all_of | ( | Iter | ini, |
Iter | fin, | ||
Predicate | f | ||
) |
Checks if all elements of a sequence fit a given predicate.
true
if for all elements e in [ini,fin)
, f(e) == true
. Referenced by none_of().
bool cxxomfort::cxxostd::any_of | ( | Iter | ini, |
Iter | fin, | ||
Predicate | f | ||
) |
Checks if any one element of a sequence fit a given predicate.
true
if for at least one elements e in [ini,fin)
, f(e) == true
. Referenced by none_of().
bool cxxomfort::cxxostd::none_of | ( | Iter | ini, |
Iter | fin, | ||
Predicate | f | ||
) |
Checks if no elements of a sequence fit a given predicate.
true
if for no elements e in [ini,fin)
, f(e) == true
. std::pair<T const&, T const&> cxxomfort::cxxostd::minmax | ( | T const & | a, |
T const & | b, | ||
Comparator | Less | ||
) |
Return a pair(min,max)
from two arguments and a comparator Less .
pair
(min, max) Referenced by minmax_element().
std::pair<T const&, T const&> cxxomfort::cxxostd::minmax | ( | T const & | a, |
T const & | b | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Referenced by minmax_element().
std::pair<FIterator,FIterator> cxxomfort::cxxostd::minmax_element | ( | FIterator | ini, |
FIterator | fin, | ||
Comparator | less | ||
) |
Returns the pair (minimum,maximum) for the given sequence and comparator less
.
less | A comparator object with the same semantics as std::less . |
std::pair
containing the minimum and maximum. Referenced by minmax_element().
std::pair<FIterator,FIterator> cxxomfort::cxxostd::minmax_element | ( | FIterator | ini, |
FIterator | fin | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool cxxomfort::cxxostd::is_permutation | ( | It1 | ini1, |
It1 | fin1, | ||
ItA | iniA | ||
) |
Returns true if range [iniA,finA] (with internally calculated finA) is a permutation of range [ini1,fin1).
Referenced by prev_permutation().
bool cxxomfort::cxxostd::next_permutation | ( | BidirIt | ini, |
BidirIt | fin, | ||
Compare | Less | ||
) |
Shuffles the sequence to become the next_permutation
bool cxxomfort::cxxostd::prev_permutation | ( | BidirIt | ini, |
BidirIt | fin, | ||
Compare | less | ||
) |
Shuffles the sequence to become the previous permutation
std::string cxxomfort::cxxostd::to_string | ( | NativeType | ) |
Converts an integral variable into a std::string
.
integer | A variable of one of C++'s integer ("integral") types (see overloads). |
std::string
|
inline |
Compare two sequences [ini1,fin1) and [ini2,fin2) for equality given comparator eq
. Four-iterators overload.
[in] | ini1,fin1 | Delimiters for the first sequence argument to compare. |
[in] | ini2,fin2 | Delimiters for the second sequence argument to compare. |
eq | An equality compare object. |
std::equal
. true
if both ranges have equal elements. Referenced by mismatch().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::pair<InputIt1, InputIt2> cxxomfort::cxxostd::mismatch | ( | InputIt1 | ini1, |
InputIt1 | fin1, | ||
InputIt2 | ini2, | ||
InputIt2 | fin2, | ||
BinaryPredicate | p | ||
) |
Finds the first difference (dif1,dif2) between two sequences [ini1,fin1) and [ini2,fin2), given comparator eq
. Four-iterator overload.
p | An equality compare object. |
std::mismatch
. Referenced by is_permutation(), and mismatch().
std::pair<InputIt1, InputIt2> cxxomfort::cxxostd::mismatch | ( | InputIt1 | ini1, |
InputIt1 | fin1, | ||
InputIt2 | ini2, | ||
InputIt2 | fin2 | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Creates a unique_ptr holding a constructed object.
unique_ptr
holding a T constructed by the given argumentsT& cxxomfort::cxxostd::get | ( | std::tuple< TupleArgs... > & | ) |
Return a member of a tuple given its type as a template argument.
get< type >(std::tuple&& sometuple)
Given a std::tuple
type with component types TupleArgs... , the new C++14 overload of std::get()
is provided that gives access to the element of type T in the tuple, assuming there is one element in TupleArgs with type T .
CXXOMFORT_IMPLEMENTS_tuple_get_type notifies if this function can be enabled. T const& cxxomfort::cxxostd::get | ( | std::tuple< TupleArgs... > const & | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexcept |
returns a const
view of object t
. A C++17 Backports .
const
qualifier added.Referenced by as_ptr_const().
|
inlinenoexcept |
returns a const
view of a pointer t
. An extension to as_const()
.
Integral cxxomfort::cxxostd::to_integer | ( | byte | b | ) |
Converts the byte value into an Integral .
byte
to an integral value.byte
value to an Integral type.
constexpr T const & clamp | ( | T const & | val, |
T const & | lo, | ||
T const & | hi, | ||
Compare | comp | ||
) |
Clamps a value.
hi < lo
.constexpr
functions can not perform assert or throw checks in their code. As such in C++11, while clamp()
is constexpr
it has no precondition checks. Referenced by clamp(), and cxxomfort::fix::clamp().
CXXO_CONSTEXPR T const& cxxomfort::cxxostd::clamp | ( | T const & | val, |
T const & | lo, | ||
T const & | hi | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
dependent_type_t cxxomfort::cxxostd::invoke | ( | F && | callable, |
Args &&... | args | ||
) |
Invokes a callable. See also invoke_r()
.
callable( args... )
, accounting for eg.: member-pointer callables. callable( args... )
, accounting for eg.: member-pointer callables. invoke()
calls a functionlike or callable f with the given arguments args... , taking care of forwarding, member function pointers, etc.
invoke(f, 1, 2, 3, ...)
is in general equivalent to f(1, 2, 3, ...)
.
With member functions, invoke(C::*f, a, b, c, ...)
is in general equivalent to a.*f(b, c, ...)
.
The invoke()
feature is backported down to C++11 with full support, and down to C++03 with partial support. The macro CXXOMFORT_IMPLEMENTS_invoke
informs about implementation status.
invoke()
may not necessarily be constexpr
.invoke()
is partially supported; in particular, invoke()
is mostly / only supported for compilers that have CXXO_COMPILER_SUPPORT_typeof == true
so return type deduction can be provided, and only supports object
callables. Older compilers without typeof or any other similar measure should be using invoke_r()
instead.invoke()
is supported, invoke()
only supports object-like callables. To use with eg.: member function pointers, wrap those in mem_fn()
, std::function
, etc.invoke()
support will also set the SD6 macro __cpp_lib_invoke
where necessary. Referenced by apply(), bind_front(), and not_fn().
R cxxomfort::cxxostd::invoke_r | ( | F && | callable, |
Args &&... | args | ||
) |
Invokes a callable and specifies a return type. See also invoke()
.
(R)callable( args... )
, specifying the return type. (R)callable( args... )
, specifying the return type. invoke_r()
calls a functionlike or callable f with the given arguments args... , taking care of forwarding, member function pointers, and implicitly converts the resulting value to type R during return.
invoke_r<R>(f, 1, 2, 3, ...)
is in general equivalent to static_cast<R>(f(1, 2, 3, ...))
.
The invoke_r()
feature is backported down to C++11 with full support, and down to C++98 with partial support. Unlike invoke()
which requires type deduction for return, invoke_r()
can be used even in compilers that lack typeof
. The macro CXXOMFORT_IMPLEMENTS_invoke_r
informs about implementation status.
invoke_r()
may not necessarily be constexpr
.invoke_r()
only supports object-like callables. To use with eg.: member function pointers, wrap those in mem_fn()
, std::function
, etc.
|
inline |
Returns the size (number of elements) of a sequence / container expression.
c.size()
or an equivalent construct for a sequence. Referenced by array< T, N >::at(), cxxomfort::at_or(), and cxxomfort::atindex_or().
constexpr auto cxxomfort::cxxostd::data | ( | C & | container | ) | -> decltype(container.data()) |
provides access to an internal "<code>.data()</code>" member.
c.data()
or a similar construct for contiguous-storage sequences.data(c)
invokes c.data()
for container for which it exists. The result type is assumed to be a pointer type or equivalent that provides direct access to a contiguous storage.
pointer
and const_pointer
. bool cxxomfort::cxxostd::data | ( | C const & | container | ) |
provides access to an internal "<code>.empty()</code>" member.
empty(c)
invokes c.empty()
for container for which it exists. The result type is assumed to be a bool
.
value_type
member type. bool cxxomfort::cxxostd::empty | ( | C const & | c | ) |
Accesses and returns the .empty() member of the container.
.empty() on the container. Referenced by data().
size_t cxxomfort::cxxostd::size | ( | C const & | c | ) |
C::pointer cxxomfort::cxxostd::data | ( | C const & | c | ) |
T cxxomfort::cxxostd::make_from_tuple | ( | std::tuple< TupleArgs... > && | Tuple | ) |
Create an object from a tuple expression.
The call make_from_tuple<T>( footuple )
is equivalent to the call T (get<0>(footuple), get<1>(footuple), get<2>(footuple), ...)
.
implementation_defined_t cxxomfort::cxxostd::apply | ( | F | f, |
Tuple & | t | ||
) |
Applies the tuple t as the arguments to the functionlike / callable f .
f | A callable / function-like argument. |
t | A std::tuple or similar construct. |
f(t...)
returns. Example usage:
Referenced by bind_front().
implementation_defined_t cxxomfort::cxxostd::bind_front | ( | Fn && | callable, |
Binds &&... | args | ||
) |
Wraps a function and its first n arguments in a callable object.
args | A sequence of arguments that are bound to the callable. |
Given a callable object or function fn taking n arguments and a sequence args of at most n arguments, bind_front
(fn,args...) returns a callable object wf of undetermined type that wraps fn and args such as at a later point of use the invocation wf(call_args...)
, fn is invoked via invoke()
with the lists of arguments args and call_args in sequence.
In other words, bind_front()
functions exactly like bind()
except that it only binds the first few arguments.
not_fn_t<Fn> cxxomfort::cxxostd::not_fn | ( | Fn && | f | ) |
Creates a function wrapper that returns the negation of a given function-like / callable.
f | A function-like callable with operator() . |
nf(args...) == !(f(args...))
.not_fn()
from Fundamentals v2: a generic functor negator. The macro CXXOMFORT_IMPLEMENTS_not_fn
informs about the implementation status. Additionally in C++>=11 mode, cxxomfort sets the macro __cpp_lib_not_fn
if this facility is backported.
void cxxomfort::cxxostd::destroy_at | ( | T * | p | ) |
Destructs an object, as if the destructor was invoked via Type::~Type()
.
Referenced by destroy(), destroy_n(), and uninitialized_default_construct_n().
void cxxomfort::cxxostd::destroy | ( | Iter | ini, |
Iter2 | fin | ||
) |
Destructs a sequence of objects.
Referenced by uninitialized_default_construct(), and uninitialized_default_construct_n().
void cxxomfort::cxxostd::destroy_n | ( | Iter | ini, |
Integer | n | ||
) |
Destructs a sequence of objects.
Referenced by uninitialized_default_construct_n().
void cxxomfort::cxxostd::uninitialized_default_construct | ( | It | ini, |
It | fin | ||
) |
Default-constructs objects in uninitialized memory.
<tt>bad_alloc</tt>. |
void cxxomfort::cxxostd::uninitialized_default_construct_n | ( | It | ini, |
Integer | n | ||
) |
Default-constructs objects in uninitialized memory.
<tt>bad_alloc</tt>. |
|
inline |
Outputs a string to a stream, quoted.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
CXXO_CONSTEXPR14 std::reverse_iterator<It> cxxomfort::cxxostd::make_reverse_iterator | ( | It | i | ) |
Constructs the reverse_iterator for a given iterator.
FwIt cxxomfort::cxxostd::iota | ( | FwIt | ini, |
FwIt | fin, | ||
T | i0 | ||
) |
Fills a sequence with a sequentially growing set of values. "Numeric" iota.
Given the sequence [ini, fin)
, iota assigns the values i0, i0+1, i0+2, ...
to the elements of the sequence until it has been filled.
[ini, fin)
is valid and writable.FwIt cxxomfort::cxxostd::iota_n | ( | FwIt | ini, |
Integer | n, | ||
T | i0 | ||
) |
Fills a sequence with a sequentially growing set of values.
Given the sequence starting at ini , iota
assigns the values i0, i0+1, i0+2, ...
to the n elements of the sequence until the n -th element has been reached.
[ini, ini+n)
is valid and writable.CXXO_CONSTEXPR Num1 cxxomfort::cxxostd::gcd | ( | Num1 | n1, |
Num2 | n2 | ||
) |
Calculates the greatest common divisor.
Referenced by lcm().
CXXO_CONSTEXPR Num1 cxxomfort::cxxostd::lcm | ( | Num1 | n1, |
Num2 | n2 | ||
) |
Calculates the lowest common multiple.
|
inline |
Returns the midpoint between two numeric values, avoiding overflows.
(n1 + n2)/2
, avoiding overflows.Referenced by midpoint().
Pointer cxxomfort::cxxostd::midpoint | ( | Pointer | p1, |
Pointer | p2 | ||
) |
Returns the midpoint between two pointers.
T | A pointer type (not a member pointer type). |
Pointer
is a pointer type-T& cxxomfort::cxxostd::declval | ( | ) |
Expression for an unevaluated context. "Type Utilities" declval.