cxxomfort  rel.20210622
Simple backports for C++ - http://ryan.gulix.cl/fossil.cgi/cxxomfort/
Files | Namespaces | Classes | Typedefs | Functions
"Implementation Fixes"

Fixes to features in std. More...

Files

file  string_helpers.hpp
 Implementation of global string accessors for C++.This header adds global functions to access the functionality of the following std::string and sibling members:
 

Namespaces

 cxxomfort::fix
 Fixes for implementation issues in std.
 

Classes

struct  integral_limits< T >
 An extension to numeric_limits that deals specifically with integer-like types. More...
 
struct  malloc_deleter
 Deleter operator that uses free() for malloc-reserved blocks. More...
 
struct  shuffle_order_engine< Engine, K >
 Forwarder for std::shuffle_order_engine. More...
 
class  errc
 Aliases a broken std::errc implementation (as a namespace rather than as a type) in MSVC 2010. More...
 

Typedefs

typedef shuffle_order_engine< minstd_rand, 256 > knuth_b
 Forwarder for the std::knuth_b specialization of shuffle_order_engine .
 

Functions

template<typename Integral >
 to_byte (Integral i) CXXO_NOEXCEPTNOTHROW
 Creates a std::byte value given a numerical octet 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 T >
bool to_bool (std::shared_ptr< T > const &p) noexcept
 
template<typename T >
bool to_bool (std::unique_ptr< T > const &p) noexcept
 
static int randmo (int mo) CXXO_NOEXCEPTNOTHROW
 Invokes rand and rids of some of the bias from the modulo. More...
 
static CXXO_CONSTEXPR errc to_errc (int E)
 Creates a value of type errc given a numeric error code.
 

Detailed Description

Fixes to features in std.

Some features in namespace std are implemented with issues or in unusable fashion in some compilers, and as such cxxomfort can not reuse the names to provide fixed versions.

To deal with this, namespace cxxomfort::fix offers a number of alternatives or "forwarders" for the features in namespace std. These names either redirect to the std one if it's working, or to an implementation in cxxomfort when they are not.

Examples of features here:

Function Documentation

◆ to_byte()

cxxomfort::fix::to_byte ( Integral  i)
inline

Creates a std::byte value given a numerical octet value.

Returns
A std::byte value .
See also
std::byte

See std::byte for more information.

Referenced by cxxomfort::cxxostd::operator!=().

◆ cdata()

auto cxxomfort::fix::cdata ( C const &  container) -> decltype(container.data())

Returns container.data() as a const-pointer for a given container.

Parameters
containerA container or expression representing one.
Returns
An iterator of the type of container.data(); pre-C++11, a Container::const_pointer .
Precondition
The argument implements the .data() member with the required semantics (contiguous storage).

◆ to_bool() [1/2]

bool cxxomfort::fix::to_bool ( std::shared_ptr< T > const &  p)
inlinenoexcept

Returns true if the shared_ptr currently hosts a value.

◆ to_bool() [2/2]

bool cxxomfort::fix::to_bool ( std::unique_ptr< T > const &  p)
inlinenoexcept

Returns true if the unique_ptr currently hosts a value.

◆ randmo()

static int cxxomfort::fix::randmo ( int  mo)
inlinestatic

Invokes rand and rids of some of the bias from the modulo.

Parameters
moAn integer.
Returns
An integer in the range [0, mo).
Exceptions
None.