Fixes to features in std.
More...
|
| 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:
|
| |
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:
s("text") to construct basic_string s.
sv"text") to construct basic_string_view s.
to_byte() - Allows std::byte construction pre-C++14 where uniform initialization for enum classes without constructors is not available.
to_bool() for smart pointers to check their managed status.
to_value() for integral_constant for versions of C++ where the integral conversion operator is not available.
to_errc() - Allows std::errc code construction from integers pre-C++14.
cxxomfort::fix::common_type - Bypasses incorrect implementation in MSVC 2010 where it misses out variadic support and some specific decay case conventions.
cxxomfort::fix::errc - Bypasses incorrect std::errc definition in MSVC versions due to it being declared there as a namespace.
cxxomfort::fix::hash hash<> - An extended, extensible version of std::hash from <functional> that forwards to the std one but also can beb specialized for families ot types.
randmo(uint) - Obtains a "random" number the same way as rand does, except it discards some bias.
◆ 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
-
| container | A 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
-
- Returns
- An integer in the range
[0, mo).
- Exceptions
-