cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Namespace of the cxxomfort
library.
More...
Namespaces | |
cxxostd | |
Backports made available by cxxomfort. | |
fix | |
Fixes for implementation issues in std. | |
library | |
Supplements to backports and other utilities. | |
st_math | |
Namespace for compile-time static (template based) arithmetic operations. | |
Classes | |
class | array |
cxxomfort's implementation of std::array . More... | |
struct | constexpr_t |
Tag type for constexpr . More... | |
struct | enum_sample |
Sample enum that can be used to figure out size and signedness of enums at compiletime. More... | |
struct | info |
struct | noop_t |
noop function More... | |
struct | OpaqueNative |
Wraps and tags a native C type as an opaque type. More... | |
class | outp |
denotes a reference used as an output argument to a function. More... | |
struct | piecewise_construct_t |
Tag indicator for piecewise construction in pair . More... | |
struct | prio |
priority tag struct, for ordering of function specializations. More... | |
struct | rvoid |
regular void This is basically a "null type": it can only be default-constructed and copy-constructed, it does not hold a value, and it can be returned from functions. More... | |
struct | tm_date |
A storage-only class to store the date component of a struct std::tm . More... | |
struct | tm_time |
A storage-only class to store the time component of a struct std::tm . More... | |
Typedefs | |
typedef tinyint_< signed char > | tinyint |
Numeric type that models a 1-byte signed int (like int8_t ). | |
typedef tinyint_< unsigned char > | tinyuint |
Numeric type that models a 1-byte unsigned int (like uint8_t ). | |
typedef rvoid | None_t |
Functions | |
template<class IIt , class OIt > | |
OIt | move (IIt ini, IIt fin, OIt dest) |
Move-assigns the objects from sequence [ini,fin) to sequence at dest . More... | |
template<class IIt , class OIt > | |
OIt | move_backward (IIt ini, IIt fin, OIt dest) |
Move-assigns the objects from sequence [ini,fin) to sequence at dest , in reverse order. More... | |
template<typename T > | |
CXXO_CONSTEXPR T | min (constexpr_t, T a, T b) CXXO_NOEXCEPTNOTHROW |
template<typename T > | |
CXXO_CONSTEXPR T | max (constexpr_t, T a, T b) CXXO_NOEXCEPTNOTHROW |
bool | bool_once (bool &flag) CXXO_NOEXCEPTNOTHROW |
Evaluates a bool variable and "unchecks" it, returnnig its old value. More... | |
template<typename T > | |
T const * | coalesce_ptrs (T *... ptrs) noexcept |
Examines a series of pointers and returns the value in the first non-NULL element among them. More... | |
template<typename Iter > | |
Iter | coalesce (Iter ini, Iter fin) CXXO_NOEXCEPTNOTHROW |
Coalesces a sequence, returning the first non-NULL element, or the last element. More... | |
template<typename R , typename... T> | |
constexpr std::array< R, sizeof...(T) > | make_array (T &&... t) |
Creates a std::array from a list of arguments. More... | |
template<typename R , typename... T> | |
constexpr cxxomfort::array< R, sizeof...(T) > | make_cxxo_array (T &&... t) |
Creates a cxxomfort::array from a list of arguments. More... | |
template<typename T , typename... Args> | |
std::array< T, sizeof...(Args)> | make_array (Args...&&args) |
Makes a std::array from an argument list. More... | |
template<typename A , typename B > | |
pair< A, B > | make_pair (A const &a, B const &b) |
make_pair idiom | |
template<typename C > | |
C::const_reference | at_or (C const &cont, typename C::size_type ind, typename C::const_reference alt) CXXO_NOEXCEPTNOTHROW |
Accesses the ind -th element of cont if it exists, else alt . More... | |
template<typename C > | |
C::reference | at_or (C &cont, typename C::size_type ind, typename C::reference alt) CXXO_NOEXCEPTNOTHROW |
at_or | |
template<typename C > | |
C::value_type const & | atindex_or (C const &cont, typename C::size_type ind, typename C::const_reference alt) CXXO_NOEXCEPTNOTHROW |
Accesses the ind -th element of cont if it exists, else alt . More... | |
Variables | |
const noop_t | noop |
noop functor - when evaluated with arguments, it does nothing | |
Namespace of the cxxomfort
library.
doc} impl/11-minmax.hppdoc} impl/11-permutations.hpp
doc} impl/17-clamp.hpp
Helper utilities to work with tuples.
Interfaces defined here:
is_tuple
tuple_index
tuple_unshift_type
, tuple_unshift
doc} "../impl/p0792r0-function_ref.hpp"
doc} "impl/p0040-memory_management.hpp"
"../impl/n3334-array_ref.hpp"}
struct cxxomfort::constexpr_t |
Tag type for constexpr
.
This is used by some cxxomfort utilities to disambiguate provided function calls that only differ on whether they can work in constexpr
context.
struct cxxomfort::OpaqueNative |
Wraps and tags a native C type as an opaque type.
OpaqueNative
takes a native C type, like int
or float
and wraps it with a Tag type as an opaque (named) type. The result is a type that can be used by explicitly accessing the underlying type where desired.
The wrapper provides access to the underlying object via the value
member, but the opaque interface is used via the value()
and opaque()
functions.
struct cxxomfort::piecewise_construct_t |
Tag indicator for piecewise construction in pair
.
Exposes a generic "None" type.
OIt cxxomfort::move | ( | IIt | ini, |
IIt | fin, | ||
OIt | dest | ||
) |
Move-assigns the objects from sequence [ini,fin) to sequence at dest .
Referenced by cxxomfort::detail::explicit_cast(), move_backward(), unique_ptr< T, D >::operator=(), unique_ptr< T, D >::reset(), cxxomfort::impl::swap_if(), and unique_ptr< T, D >::unique_ptr().
OIt cxxomfort::move_backward | ( | IIt | ini, |
IIt | fin, | ||
OIt | dest | ||
) |
Move-assigns the objects from sequence [ini,fin) to sequence at dest , in reverse order.
CXXO_CONSTEXPR T cxxomfort::min | ( | constexpr_t | , |
T | a, | ||
T | b | ||
) |
constexpr variant of min()
constexpr
version of std::min()
Referenced by basic_string_view< Ch, ChT >::copy(), array_ref< CharTy const >::rightmost(), splitmix64::splitmix64(), and basic_string_view< Ch, ChT >::substr().
CXXO_CONSTEXPR T cxxomfort::max | ( | constexpr_t | , |
T | a, | ||
T | b | ||
) |
constexpr variant of max()
constexpr
version of std::max()
Referenced by splitmix64::splitmix64().
bool cxxomfort::bool_once | ( | bool & | flag | ) |
Evaluates a bool
variable and "unchecks" it, returnnig its old value.
flag | A writable bool type value. |
Never | throws. |
true
once.The use case is such as performing repetitive tasks eg.: inside a loop, but where the very first iteration of the loop has a different, added code path:
See also std::exchange()
.
|
noexcept |
Examines a series of pointers and returns the value in the first non-NULL element among them.
p1,p2,... | A list of pointers to T . |
Never | throws. |
The function is variadic in C++≥11; in versions before it can take up to 5 arguments.
The funcion is noexcept
in C++≥11, and marked throw()
in versions before if the compiler supports it.
Iter cxxomfort::coalesce | ( | Iter | ini, |
Iter | fin | ||
) |
Coalesces a sequence, returning the first non-NULL element, or the last element.
ini,fin | Iterators working as pointer-like elements. |
Never | throws. |
The function assumes pointer-like interface for the iterator type and thus never throws (is marked noexcept
for C++≥11). Attempting to use it with an iterator type that can throw on dereference is unsupported.
constexpr std::array<R, sizeof...(T) > cxxomfort::make_array | ( | T &&... | t | ) |
Creates a std::array
from a list of arguments.
experimental/lfv2
)The expression make_array<V>(arguments...)
creates an array as follows:
This is added to namespace std::experimental
.
The accessory function make_cxxo_array()
creates a cxxomfort::array
instead.
std::common_type
. constexpr cxxomfort::array<R, sizeof...(T) > cxxomfort::make_cxxo_array | ( | T &&... | t | ) |
Creates a cxxomfort::array
from a list of arguments.
experimental/lfv2
)experimental/lfv2
)This function is similar to make_array()
except it creates a cxxomfort::array
instead. It is part of "Implementation Fixes" .
std::array<T, sizeof...(Args)> cxxomfort::make_array | ( | Args...&& | args | ) |
Makes a std::array
from an argument list.
args... | The list of elements that goes into the array. |
T | The element type (value_type ) of the returned array . |
make_array()
creates a std::array given an argument list and a type to which the arguments are converted for placing them in the array. The array returned has a size equal to the number of arguments passed.
The function takes one template parameter T , which is the element type of the returned array. Starting with C++11, if the type given here is void
, the type of the array will be automatically deduced if possible as per std::common_type
. Pre-C++11, the type T must be given explicitly.
C::const_reference cxxomfort::at_or | ( | C const & | cont, |
typename C::size_type | ind, | ||
typename C::const_reference | alt | ||
) |
Accesses the ind -th element of cont if it exists, else alt .
cont | A container or container-like object supporting member .at() . |
ind | An index. |
alt | An alternative return value if a suitable element in cont is not found. |
noexcept | Never throws. |
This function encapsulates the idiom of accessing the i-th element of C, or a suitable default A if no i-th element is found. Such an idiom already exists for other components in the form of eg.: variant/optional get_if<I>()
.
at_or()
is marked noexcept
. It is intended to never throw, as it checks the precondition to access the element in C
's .at()
before accessing. No practical implementation of .size()
or relational operators could be thought that throws, so this is safe to do.
C::value_type const& cxxomfort::atindex_or | ( | C const & | cont, |
typename C::size_type | ind, | ||
typename C::const_reference | alt | ||
) |
Accesses the ind -th element of cont if it exists, else alt .
cont | A container or container-like object supporting member .at() . |
ind | An index. |
alt | An alternative return value if a suitable element in cont is not found. |
noexcept | Never throws. |
This function encapsulates the idiom of accessing the i-th element of C, or a suitable default A if no i-th element is found. Such an idiom already exists for other components in the form of eg.: variant/optional get_if<I>()
.
atindex_or()
is similar to at_or()
in all respects but one, including being marked noexcept
; the one difference being that access is performed via member .operator[]()
; as such, if that access does not exist for cont , compilation fails.