cxxomfort  rel.20210622
Simple backports for C++ - http://ryan.gulix.cl/fossil.cgi/cxxomfort/
Classes | Typedefs | Functions
cxxomfort::cxxostd Namespace Reference

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  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  timespec
 Struct timespec, from POSIX / C++17. More...
 
class  tuple
 std::tuple<T...> implementation More...
 
class  type_index
 
class  unique_ptr
 unique_ptr: a scoped, movable smart pointer. Emulation of the unique_ptr implementation in C++11 for C++03 compilers. Original backport by Howard Hinnant. 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 .
 

Functions

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 . 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<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 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 RAIterator , class URNG >
void shuffle (RAIterator ini, RAIterator fin, URNG &g)
 Shuffles a sequence according to a generator call g(). More...
 
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 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
 
static int timespec_get (struct timespec *ts, int base)
 Returns timespec information from the system clock and writes it into ts . 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...
 
static std::string to_string (unsigned int u)
 
static std::string to_string (short i)
 
static std::string to_string (unsigned short u)
 
static std::string to_string (long long i)
 
static std::string to_string (unsigned long long u)
 
static std::string to_string (long i)
 
static std::string to_string (unsigned long u)
 
static std::string to_string (float i)
 
static std::string to_string (double i)
 
static std::string to_string (long double i)
 
static unsigned long stoul (std::string const &str, size_t *pinv, int base=10)
 Converts a string expression to a unsigned long. More...
 
static unsigned long long stoull (std::string const &str, size_t *pinv, int base=10)
 Converts a string expression to a unsigned long long. More...
 
static signed long stol (std::string const &str, size_t *pinv, int base=10)
 Converts a string expression to a long. More...
 
static signed long long stoll (std::string const &str, size_t *pinv, int base=10)
 Converts a string expression to a long long. 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)
 
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 &&f, Args &&... args)
 Invokes a callable. See also invoke_r() . More...
 
template<typename R , typename F , typename... Args>
invoke_r (F &&f, 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>
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 >
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 It >
CXXO_CONSTEXPR 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 T >
T & declval ()
 Expression for an unevaluated context. "Type Utilities" declval. More...
 
template<size_t I, typename T , size_t N>
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>
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...
 

Detailed Description

Backports made available by cxxomfort.

Namespace that holds the library's backports of named C++ features.

Function Documentation

◆ copy_if()

OutI cxxomfort::cxxostd::copy_if ( InpI  ini,
InpI  fin,
OutI  dest,
Predicate  f 
)

Copy elements conditionally to dest if they fulfill f .

Returns
the advanced dest iterator.
Data Transfer:
Copy elements from one place to another
Parameters
fA predicate that maps Inp::value_type -> bool.
See also
algorithm/copy_if @ cppreference
algorithm/copy @ cppreference

Given the sequence [ini, fin), copies those elements e inside it to dest for which the evlauation f(e) is true .

◆ copy_n()

OutI cxxomfort::cxxostd::copy_n ( InpI  ini,
Integral  n,
OutI  dest 
)
inline

Copy a given amount of elements to dest .

Returns
the iterated dest iterator.
Data Transfer:
"Algorithms" "copy_n"
See also
algorithm/copy_n @ cppreference
algorithm/copy @ cppreference

Copies n elements from ini to , unconditionally.

Referenced by array_ref< Ch const >::back(), and cxxomfort::library::algorithm::copy_leftmost_n().

◆ partition_copy()

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 .

Parameters
fA predicate that maps InpI::value_type -> bool.
Returns
the advanced std::pair (Dtrue , Dfalse ).
Data Transfer:
Conditionally copy data to either of two destinations. partition_copy
See also
algorithm/partition_copy @ cppreference
algorithm/copy_if @ cppreference

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).

◆ find_if()

CXXO_CONSTEXPR14 It cxxomfort::cxxostd::find_if ( It  ini,
It  fin,
Pred  f 
)

Finds an element in a sequence that matches a predicate.

Parameters
fA predicate that maps It::value_type -> bool.
Data Transfer:
\:
std::find_if
See also
algorithm/find_if @ cppreference
Note
This algorithm is already provided in C++03. It is provided here only for enhancements in later Standards that might be desirable to invoke backports for explicitly.
This algorithm is 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(), and cxxomfort::library::algorithm::find_if_not().

◆ 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.

Parameters
fA predicate that maps It::value_type -> bool.
Data Transfer:
"Algorithms" find_if_not
See also
algorithm/find_if @ cppreference
Note
This algorithm is constexpr starting C++20; here it is tentatively marked constexpr for C++14 as well. We can't modify the C++17 version.

◆ count_if()

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.

Parameters
fA predicate that maps It::value_type -> bool.
\:
count_if
Data Transfer:
See also
algorithm/count @ cppreference
count
Note
This algorithm is constexpr starting C++20; here it is tentatively marked constexpr for C++14 as well. We can't modify the C++17 version.

◆ count()

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.

\:
count
Data Transfer:
See also
algorithm/count @ cppreference
count_if
Note
This algorithm is 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< Ch const >::back(), is_permutation(), basic_string_view< Ch, ChT >::length(), and array_ref< Ch const >::rightmost().

◆ fill_n()

CXXO_CONSTEXPR14 void cxxomfort::cxxostd::fill_n ( It  ini,
Numeric  n,
T const &  tv 
)

Fills a sequence with a given value.

Parameters
nHow many elements to fill.
tvThe value to use to fill.
Data Transfer:
See also
algorithm/fill @ cppreference

◆ is_sorted() [1/2]

bool cxxomfort::cxxostd::is_sorted ( Iterator  ini,
Iterator  fin,
Compare  less 
)
inline

Determines if a sequence is sorted according to a given criteria.

Parameters
lessCriteria for sorting, a binary function f(x,y) that returns true if x<y.
Returns
A bool response about if the sequence is sorted.
Data Transfer:
"Algorithms" is_sorted
See also
algorithm/is_sorted @ cppreference

Referenced by is_sorted().

◆ is_sorted() [2/2]

bool cxxomfort::cxxostd::is_sorted ( Iterator  ini,
Iterator  fin 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ shuffle()

void cxxomfort::cxxostd::shuffle ( RAIterator  ini,
RAIterator  fin,
URNG &  g 
)

Shuffles a sequence according to a generator call g().

Parameters
gA writable object that acts like a (P)RNG and returns a value via operator().
Data Transfer:
"Algorithms" shuffle
Note
Requires support from <random>.

◆ for_each_n()

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.

Parameters
fA function that takes arguments and can modify them.
\:
for_each_n
Data Transfer:
Parameters
fA function object that is executed as f(i) for each i in the sequence.
See also
algorithm/for_each @ cppreference
Note
The return value of f is ignored. The "non-ignoring" equivalent is accumulate() .

◆ bit_width()

constexpr U cxxomfort::cxxostd::bit_width ( u)
noexcept

Returns the number of bits required to represent the value of u .

Precondition
std::is_unsigned<U>::value

◆ bit_floor()

constexpr U cxxomfort::cxxostd::bit_floor ( u)
noexcept

Returns u rounded down to a power of 2.

Precondition
std::is_unsigned<U>::value

◆ bit_ceil()

constexpr U cxxomfort::cxxostd::bit_ceil ( u)
noexcept

Returns u rounded up to a power of 2.

Precondition
std::is_unsigned<U>::value

◆ timespec_get()

static int cxxomfort::cxxostd::timespec_get ( struct timespec ts,
int  base 
)
inlinestatic

Returns timespec information from the system clock and writes it into ts .

\:
timespec_get
See also
POSIX timespec_get() .
time/timespec_get @ cppreference

◆ get() [1/4]

T& cxxomfort::cxxostd::get ( array< T, N > &  a)

Tuple-like interface to access an element in an array .

Template Parameters
IIndex to be accessed.
Returns
Direct access to the element in the array.

◆ get() [2/4]

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.

◆ ref()

reference_wrapper<T> cxxomfort::cxxostd::ref ( T &  t)

Wraps an object in a reference_wrapper .

Returns
reference_wrapper<T> holding the named object t .
\:
"std::reference_wrapper"
<functional>:
"std::reference_wrapper"
See also
reference_wrapper

◆ cref()

reference_wrapper<T const> cxxomfort::cxxostd::cref ( T const &  t)

Wraps an object in a reference_wrapper to const .

Returns
reference_wrapper<T const> holding the named object t .
\:
"std::reference_wrapper"
<functional>:
"std::reference_wrapper"
See also
reference_wrapper

◆ addressof()

T* cxxomfort::cxxostd::addressof ( T &  arg)
inline

◆ all_of()

bool cxxomfort::cxxostd::all_of ( Iter  ini,
Iter  fin,
Predicate  f 
)

Checks if all elements of a sequence fit a given predicate.

Returns
true if for all elements e in [ini,fin), f(e) == true.

Referenced by none_of().

◆ any_of()

bool cxxomfort::cxxostd::any_of ( Iter  ini,
Iter  fin,
Predicate  f 
)

Checks if any one element of a sequence fit a given predicate.

Returns
true if for at least one elements e in [ini,fin), f(e) == true.

Referenced by none_of().

◆ none_of()

bool cxxomfort::cxxostd::none_of ( Iter  ini,
Iter  fin,
Predicate  f 
)

Checks if no elements of a sequence fit a given predicate.

Returns
true if for no elements e in [ini,fin), f(e) == true.

◆ minmax() [1/2]

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 .

\:
Find the minimum and maximum elements in a sequence
Data Transfer:
Find the minimum and maximum elements in a sequence
Returns
A pair (min, max)
See also
algorithm/minmax @ cppreference

Referenced by minmax_element().

◆ minmax() [2/2]

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().

◆ minmax_element() [1/2]

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 .

Parameters
lessA comparator object with the same semantics as std::less .
Data Transfer:
\:
minmax_elements
Returns
A std::pair containing the minimum and maximum.

Referenced by minmax_element().

◆ minmax_element() [2/2]

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.

◆ is_permutation()

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).

Source: cppreference.com

Referenced by prev_permutation().

◆ next_permutation()

bool cxxomfort::cxxostd::next_permutation ( BidirIt  ini,
BidirIt  fin,
Compare  Less 
)

Shuffles the sequence to become the next_permutation

Data Transfer:

◆ prev_permutation()

bool cxxomfort::cxxostd::prev_permutation ( BidirIt  ini,
BidirIt  fin,
Compare  less 
)

Shuffles the sequence to become the previous permutation

Data Transfer:

◆ to_string() [1/11]

std::string cxxomfort::cxxostd::to_string ( NativeType  )

Converts an integral variable into a std::string .

Parameters
integerA variable of one of C++'s integer ("integral") types (see overloads).
Returns
a std::string
<string>:

Referenced by stoll().

◆ to_string() [2/11]

static std::string cxxomfort::cxxostd::to_string ( unsigned int  u)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [3/11]

static std::string cxxomfort::cxxostd::to_string ( short  i)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [4/11]

static std::string cxxomfort::cxxostd::to_string ( unsigned short  u)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [5/11]

static std::string cxxomfort::cxxostd::to_string ( long long  i)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [6/11]

static std::string cxxomfort::cxxostd::to_string ( unsigned long long  u)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [7/11]

static std::string cxxomfort::cxxostd::to_string ( long  i)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [8/11]

static std::string cxxomfort::cxxostd::to_string ( unsigned long  u)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [9/11]

static std::string cxxomfort::cxxostd::to_string ( float  i)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [10/11]

static std::string cxxomfort::cxxostd::to_string ( double  i)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ to_string() [11/11]

static std::string cxxomfort::cxxostd::to_string ( long double  i)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Referenced by stoll().

◆ stoul()

static unsigned long cxxomfort::cxxostd::stoul ( std::string const &  str,
size_t *  pinv,
int  base = 10 
)
inlinestatic

Converts a string expression to a unsigned long.

Parameters
baseBase to convert from, which can be 2, 8, 10 (default) or 16.
<string>:

Referenced by stoll().

◆ stoull()

static unsigned long long cxxomfort::cxxostd::stoull ( std::string const &  str,
size_t *  pinv,
int  base = 10 
)
inlinestatic

Converts a string expression to a unsigned long long.

Parameters
baseBase to convert from, which can be 2, 8, 10 (default) or 16.
<string>:

Referenced by stoll().

◆ stol()

static signed long cxxomfort::cxxostd::stol ( std::string const &  str,
size_t *  pinv,
int  base = 10 
)
inlinestatic

Converts a string expression to a long.

Parameters
baseBase to convert from, which can be 2, 8, 10 (default) or 16.
<string>:

Referenced by stoll().

◆ stoll()

static signed long long cxxomfort::cxxostd::stoll ( std::string const &  str,
size_t *  pinv,
int  base = 10 
)
inlinestatic

Converts a string expression to a long long.

Parameters
baseBase to convert from, which can be 2, 8, 10 (default) or 16.
<string>:

◆ equal() [1/2]

bool cxxomfort::cxxostd::equal ( RangeIt1  ini1,
RangeIt1  fin1,
RangeIt2  ini2,
RangeIt2  fin2,
Compare  eq 
)
inline

Compare two sequences [ini1,fin1) and [ini2,fin2) for equality given comparator eq . Four-iterators overload.

Parameters
[in]ini1,fin1Delimiters for the first sequence argument to compare.
[in]ini2,fin2Delimiters for the second sequence argument to compare.
eqAn equality compare object.
Data Transfer:
""
Returns
true if both ranges have equal elements.

Referenced by mismatch().

◆ equal() [2/2]

bool cxxomfort::cxxostd::equal ( RangeIt1  ini1,
RangeIt1  fin1,
RangeIt2  ini2,
RangeIt2  fin2 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ mismatch() [1/2]

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.

Parameters
pAn equality compare object.
Data Transfer:
""

Referenced by is_permutation(), and mismatch().

◆ mismatch() [2/2]

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.

◆ make_unique()

std::unique_ptr<T> cxxomfort::cxxostd::make_unique ( Args &&...  args)
inline

Creates a unique_ptr holding a constructed object.

Note
For compilers in pre-C++11 mode, the function can copy (forward) up to 6 arguments to the T constructor.

◆ get() [3/4]

T& cxxomfort::cxxostd::get ( std::tuple< TupleArgs... > &  )

Return a member of a tuple given its type as a template argument.

Template Parameters
Ta type, such that it exists in the type pack TupleArgs... .
Precondition
The type T exists in TupleArgs

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 .

tuple<int, string, float> tu (...);
get<string>(tu); // gets get<1>(tu), which is the std::string member
get<bool>(tu); // does not compile, no bool type in tu
Note
This functionality is backported mostly to C++03 compatible compilers with high template support. The macro CXXOMFORT_IMPLEMENTS_tuple_get_type notifies if this function can be enabled.

◆ get() [4/4]

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.

◆ as_const()

constexpr std::add_const< T >::type& cxxomfort::cxxostd::as_const ( T &  t)
inlinenoexcept

returns a const view of object t . A C++17 Backports .

Returns
A reference to its argument with const qualifier added.
See also
{n4380}

Referenced by as_ptr_const().

◆ as_ptr_const()

constexpr std::add_const< T >::type* cxxomfort::cxxostd::as_ptr_const ( T *const  t)
inlinenoexcept

returns a const view of a pointer t . An extension to as_const() .

Returns
A pointer to a const view of the argument.
\:
as_const
<utility>:
See also
{p1011r0} , as_const()

◆ to_integer()

Integral cxxomfort::cxxostd::to_integer ( byte  b)

Converts the byte value into an Integral .

◆ clamp() [1/2]

constexpr T const & clamp ( T const &  val,
T const &  lo,
T const &  hi,
Compare  comp 
)

Clamps a value.

Returns
An altered value from val to fit into the open interval (lo , hi ).
See also
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4536.html
Note
Behaviour is undefined if hi < lo.
Pre-C++14, 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::library::algorithm::is_clamped().

◆ clamp() [2/2]

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.

◆ invoke()

dependent_type_t cxxomfort::cxxostd::invoke ( F &&  f,
Args &&...  args 
)

Invokes a callable. See also invoke_r() .

<functional>:
Invoke callables via invoke(callable, args...)
See also
utility/functional/invoke @ cppreference
invoke_r()

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.

Note
In C++11 and C++14 mode, invoke() may not necessarily be constexpr .
Pre-C++11, 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. Compilers without typeof or any other similar measure should be using invoke_r() instead.
For pre-C++11 compilers without typeof, invoke() only supports object-like callables. To use with eg.: member function pointers, wrap those in mem_fn(), std::function, etc.

Referenced by apply(), bind_front(), and invoke_r().

◆ invoke_r()

R cxxomfort::cxxostd::invoke_r ( F &&  f,
Args &&...  args 
)

Invokes a callable and specifies a return type. See also invoke() .

<functional>:
Invoke callables via invoke(callable, args...)
See also
utility/functional/invoke @ cppreference
invoke()

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 .

Note
In C++11 and C++14 mode, invoke_r() may not necessarily be constexpr .
Pre-C++11, invoke_r() only supports object-like callables. To use with eg.: member function pointers, wrap those in mem_fn(), std::function, etc.

◆ size() [1/2]

C::size_type cxxomfort::cxxostd::size ( C &  c)
inline

Returns the size (number of elements) of a sequence / container expression.

\:
size

Referenced by array< T, N >::at(), cxxomfort::at_or(), and cxxomfort::atindex_or().

◆ data() [1/3]

constexpr auto cxxomfort::cxxostd::data ( C &  container) -> decltype(container.data())

provides access to an internal "<code>.data()</code>" member.

\:
data

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.

Warning
For C++ pre-C++11, this relies on the container type declaring this pointer type as the member types pointer and const_pointer.

◆ data() [2/3]

bool cxxomfort::cxxostd::data ( C const &  container)

provides access to an internal "<code>.empty()</code>" member.

\:
empty

empty(c) invokes c.empty() for container for which it exists. The result type is assumed to be a bool .

Warning
For C++ pre-C++11, this relies on the container type declaring a value_type member type.

◆ empty()

bool cxxomfort::cxxostd::empty ( C const &  c)

Accesses and returns the .empty() member of the container.

Returns
A bool, equal to calling .empty() on the container.

Referenced by data().

◆ size() [2/2]

size_t cxxomfort::cxxostd::size ( C const &  c)

Accesses and returns the .size() member of the container.

Returns
A numeric type, equal to calling .size() on the container.

◆ data() [3/3]

C::pointer cxxomfort::cxxostd::data ( C const &  c)

Accesses and returns the .data() member of the container.

Returns
A pointer, likely of type {containertype}::pointer .

Referenced by data().

◆ make_from_tuple()

T cxxomfort::cxxostd::make_from_tuple ( std::tuple< TupleArgs... > &&  Tuple)

Create an object from a tuple expression.

Returns
An object of type T , constructed via a constructor call using a tuple as arguments.
See also
 utility/make_from_tuple @ cppreference

The call make_from_tuple<T>( footuple ) is equivalent to the call T (get<0>(footuple), get<1>(footuple), get<2>(footuple), ...).

◆ apply()

implementation_defined_t cxxomfort::cxxostd::apply ( f,
Tuple &  t 
)

Applies the tuple t as the arguments to the functionlike / callable f .

Parameters
fA callable / function-like argument.
tA std::tuple or similar construct.
Returns
Whatever f(t...) returns.
See also
utility/apply @ cppreference

Example usage:

auto logdata= make_tuple("Handle %x code %u with result %s", 0x10, 300, "Hello World");
invoke(printf, logdata);
// prints:
// "Handle 0x10 code 300 with result Hello World"

Referenced by bind_front().

◆ 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.

Parameters
argsA sequence of arguments that are bound to the callable.
See also
utility/functional/bind_front @ cppreference

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.

auto wf = bind_front(fn, a1, a2, a3);
wf(b1, b2); // calls fn(a1, a2, a3, b1, b2);
Note
This feature from C++20 is backported down to at most C++11.

◆ exchange()

T cxxomfort::cxxostd::exchange ( T &  obj,
CXXO_RV_REF(U)  nval 
)

Replaces a variable's value, returns the old value.

cxx14-backports

See also
{n3668}

◆ not_fn()

not_fn_t<Fn> cxxomfort::cxxostd::not_fn ( Fn &&  f)

Creates a function wrapper that returns the negation of a given function-like / callable.

Parameters
fA function-like callable with operator().
Returns
A function object wrapper nf of undetermined type such that nf(args...) == !(f(args...)).
<functional>:
See also
utility/functional/not_fn @ cppreference
Note
In C++03 mode, this wrapper can take function-likes of up to 5 arguments.
In C++03 mode, this wrapper can only take named ("l-value") arguments.

◆ destroy_at()

void cxxomfort::cxxostd::destroy_at ( T *  p)

Destructs an object, as if the destructor was invoked via Type::~Type().

<memory>:
See also
{p0040r2}
<memory>:
See also
{p0040r2}

Referenced by destroy(), destroy_n(), and uninitialized_default_construct_n().

◆ destroy()

void cxxomfort::cxxostd::destroy ( Iter  ini,
Iter2  fin 
)

◆ destroy_n()

void cxxomfort::cxxostd::destroy_n ( Iter  ini,
Integer  n 
)

◆ uninitialized_default_construct()

void cxxomfort::cxxostd::uninitialized_default_construct ( It  ini,
It  fin 
)

Default-constructs objects in uninitialized memory.

<memory>:
Exceptions
<tt>bad_alloc</tt>.
See also
{p0040r0} .

◆ uninitialized_default_construct_n()

void cxxomfort::cxxostd::uninitialized_default_construct_n ( It  ini,
Integer  n 
)

Default-constructs objects in uninitialized memory.

<memory>:
Exceptions
<tt>bad_alloc</tt>.
See also
{p0040r0} .

◆ make_reverse_iterator()

CXXO_CONSTEXPR std::reverse_iterator<It> cxxomfort::cxxostd::make_reverse_iterator ( It  i)

Constructs the reverse_iterator for a given iterator.

\:
make_reverse_iterator
See also
iterator/make_reverse_iterator @ cppreference

◆ iota()

FwIt cxxomfort::cxxostd::iota ( FwIt  ini,
FwIt  fin,
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.

Precondition
The range [ini, fin) is valid and writable.
See also
cppref{algoritm/iota}

◆ iota_n()

FwIt cxxomfort::cxxostd::iota_n ( FwIt  ini,
Integer  n,
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.

Precondition
The range [ini, ini+n) is valid and writable.
See also
cppref{algoritm/iota}

◆ gcd()

CXXO_CONSTEXPR Num1 cxxomfort::cxxostd::gcd ( Num1  n1,
Num2  n2 
)

Calculates the greatest common divisor.

\:
gcd
Returns
A numeric value of type Num1 . Compare also: lcm
See also
numeric/gcd @ cppreference
Note
As a backport, the return type is the same as the first argument.

Referenced by lcm().

◆ lcm()

CXXO_CONSTEXPR Num1 cxxomfort::cxxostd::lcm ( Num1  n1,
Num2  n2 
)

Calculates the lowest common multiple.

\:
lcm
Returns
A numeric value of type Num1 . Compare also: gcd
See also
numeric/lcm @ cppreference

◆ declval()

T& cxxomfort::cxxostd::declval ( )

Expression for an unevaluated context. "Type Utilities" declval.

<utility>:
declval

Referenced by invoke_r().