cxxomfort
rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
|
Fixes for implementation issues in std. More...
Classes | |
struct | integral_limits |
An extension to numeric_limits that deals specifically with integer-like types. More... | |
struct | is_contiguous_access_iterator |
Tags an iterator as a contiguous access type iterator. More... | |
struct | malloc_deleter |
Deleter operator that uses free() for malloc -reserved blocks. More... | |
struct | shuffle_order_engine |
Forwarder for std::shuffle_order_engine . More... | |
Typedefs | |
typedef shuffle_order_engine< minstd_rand, 256 > | knuth_b |
Forwarder for the std::knuth_b specialization of shuffle_order_engine .See shuffle_order_engine above. | |
Functions | |
template<typename T > | |
constexpr T | clamp (cxxomfort::constexpr_t, T x, T Min, T Max) noexcept |
template<typename It , typename T > | |
constexpr It | find (cxxomfort::constexpr_t const, It ini, It fin, T const &value) |
template<typename It , typename Fn > | |
constexpr It | find_if (cxxomfort::constexpr_t const, It ini, It fin, Fn &&fn) |
template<typename It , typename T > | |
constexpr size_t | count (cxxomfort::constexpr_t const, It ini, It fin, T const &value) noexcept |
template<typename It , typename Fn > | |
constexpr size_t | count_if (cxxomfort::constexpr_t const, It ini, It fin, Fn &&fn) noexcept |
template<typename Integral > | |
constexpr std::byte | to_byte (Integral i) noexcept |
Constructs a std::byte using an integral value. More... | |
template<typename T > | |
auto | cdata (C const &container) -> decltype(container.data()) |
Returns container.data() as a const-pointer for a given container. More... | |
template<typename It , typename = typename std::enable_if<std::is_pointer<It>::value, bool>> | |
constexpr It | static_next (It const p) noexcept |
Given a compile-time const (or constexpr ) iterator, returns the iterator to the next position. | |
template<typename It , typename = typename std::enable_if<std::is_pointer<It>::value, bool>> | |
constexpr It | static_prev (It const p) noexcept |
Given a compile-time const (or constexpr ) iterator, returns the iterator to the previous position. More... | |
template<typename T > | |
bool | to_bool (std::shared_ptr< T > const &p) noexcept |
template<typename T > | |
bool | to_bool (std::unique_ptr< T > const &p) noexcept |
template<class Ty , Ty u> | |
CXXO_CONSTEXPR Ty | to_integer (std::integral_constant< Ty, u > const) CXXO_NOEXCEPTNOTHROW |
Returns the value corresponding to a integral_constant .-utils Recovers the value corresponding to a integral_constant . More... | |
template<class Ty , Ty u> | |
CXXO_CONSTEXPR Ty | to_value (std::integral_constant< Ty, u > const) CXXO_NOEXCEPTNOTHROW |
Returns the value corresponding to a integral_constant . More... | |
Fixes for implementation issues in std.
Namespace that holds fixes and alternative implementations or names for stuff in C++ std that can not be modified or reimplemented.
See "Implementation Fixes" for more details.
struct cxxomfort::fix::integral_limits |
An extension to numeric_limits
that deals specifically with integer-like types.
For a given integral or integer-like type Ty , integral_limits<Ty>
provides an interface to std::numeric_limits<Ty>
and in fact inherits from the latter. The interface is expanded to add some useful information about the integral type that is only available at compile time as macros pre-C++11.
integral_limits
provides the following new members:
const_min
- minimum value as a value (min
is constexpr function in C++>=11).const_max
- maximum value as a value (max
is constexpr function in C++>=11).digits_base<N>
- the total number of digits required to represent any value in the given base.Pending members :
narrower_type
- an alias to the next smaller integral type of the same signedness.wider_type
- an alias to the next larger integral type of the same signedness.lo_mask
- an integral value that can be AND-ed with this type to keep only the lower bits.hi_mask
- an integral value that can be AND-ed with this type to keep only the higher bits.cxxomfort provides specializations of the new integral_limits
for all the types that are defined as integral. The list explicitly includes:
short, int, long, long long
in their signed and unsigned variants.
struct cxxomfort::fix::is_contiguous_access_iterator |
Tags an iterator as a contiguous access type iterator.
Given an iterator type I, indicates whether the type either:
contiguous_iterator_tag
tagPre C++17, this can only be implemented as an heuristic and can not determine contiguousness of storage types where the iterator is being wrapped, in which cases it will always declare false
.
One such example is <array>
and <vector>
iterators in MSVC, in versions that don't support disabling the debug iterator mode.
struct cxxomfort::fix::shuffle_order_engine |
Forwarder for std::shuffle_order_engine
.
Some compilers, such as MSVC 2008, 2010, don't implement shuffle_order_engine
, and some other compilers don't implement it at all. This name will redirect to cxxomfort's implementation in those cases, or to std::shuffle_order_engine
otherwise.
|
inlinenoexcept |
Implementation of std::clamp
with constexpr
Referenced by cxxomfort::library::algorithm::is_clamped().
constexpr It cxxomfort::fix::find | ( | cxxomfort::constexpr_t | const, |
It | ini, | ||
It | fin, | ||
T const & | value | ||
) |
constexpr
capability to std::find()
Adds an "overload" to std::find()
so that pre-C++20 can invoke it in constexpr in contexts where the compiler makes it possible.
Referenced by basic_string_view< Ch, ChT >::find(), find_if(), and cxxomfort::cxxostd::is_permutation().
constexpr It cxxomfort::fix::find_if | ( | cxxomfort::constexpr_t | const, |
It | ini, | ||
It | fin, | ||
Fn && | fn | ||
) |
constexpr
capability to std::find_if()
Adds an "overload" to std::find_if()
so that pre-C++20 can invoke it in constexpr in contexts where the compiler makes it possible.
|
noexcept |
constexpr
capability to std::count()
Adds an "overload" to std::count()
so that pre-C++20 can invoke it in constexpr in contexts where the compiler makes it possible.
|
noexcept |
constexpr
capability to std::count_if()
Adds an "overload" to std::count_if()
so that pre-C++20 can invoke it in constexpr in contexts where the compiler makes it possible.
|
noexcept |
Constructs a std::byte
using an integral value.
byte
.Create byte
values.
Referenced by to_byte().
auto cxxomfort::fix::cdata | ( | C const & | container | ) | -> decltype(container.data()) |
Returns container.data()
as a const-pointer for a given container.
container | A container or expression representing one. |
container.data()
; pre-C++11, a Container::const_pointer
. .data()
member with the required semantics (contiguous storage).
|
noexcept |
Given a compile-time const
(or constexpr
) iterator, returns the iterator to the previous position.
|
inlinenoexcept |
Returns true
if the shared_ptr
currently hosts a value.
Referenced by to_value().
|
inlinenoexcept |
Returns true
if the unique_ptr
currently hosts a value.
|
inline |
Returns the value corresponding to a integral_constant
.-utils Recovers the value corresponding to a integral_constant
.
This function is a helper for versions of C++ pre-C++14 which introduced the integral_constant
conversion operator and function call.
|
inline |
Returns the value corresponding to a integral_constant
.
integral_constant
. This function is a helper for versions of C++ pre-C++14 which introduced the integral_constant
conversion operator and function call.