New lexcical_cast header. More...
#include "utils/charconv.hpp"#include "utils/optional_fwd.hpp"#include <limits>#include <string>#include <sstream>#include <type_traits>Go to the source code of this file.
Classes | |
| struct | bad_lexical_cast |
| Thrown when a lexical_cast fails. More... | |
| struct | implementation::lexical_caster< To, From, ToEnable, FromEnable > |
| Base class for the conversion. More... | |
| struct | implementation::is_arithmetic_v< From > >> |
| Specialized conversion class. More... | |
| struct | implementation::lexical_caster< bool, std::string_view, void, void > |
| Specialized conversion class. More... | |
| struct | implementation::lexical_caster< To, std::string_view, std::enable_if_t< std::is_arithmetic_v< To > >, void > |
| Specialized conversion class. More... | |
| struct | implementation::lexical_caster< To, std::string, std::enable_if_t< std::is_arithmetic_v< To > >, void > |
| Specialized conversion class. More... | |
| struct | implementation::is_same_v< From, char * > >> |
| Specialized conversion class. More... | |
Namespaces | |
| implementation | |
| Contains the implementation details for lexical_cast and shouldn't be used directly. | |
Macros | |
| #define | LEXICAL_CAST_HPP_INCLUDED |
| #define | DEBUG_THROW(id) |
Functions | |
| template<typename To , typename From > | |
| To | lexical_cast (From value) |
| Lexical cast converts one type to another. More... | |
| template<typename To , typename From > | |
| To | lexical_cast_default (From value, To fallback=To()) |
| Lexical cast converts one type to another with a fallback. More... | |
New lexcical_cast header.
For debugging you can include this header in a namespace (to honor ODR) and have a set of functions that throws exceptions instead of doing the real job. This is done for the unit tests but should normally not be done.
Definition in file lexical_cast.hpp.
| #define DEBUG_THROW | ( | id | ) |
Definition at line 53 of file lexical_cast.hpp.
| #define LEXICAL_CAST_HPP_INCLUDED |
Definition at line 30 of file lexical_cast.hpp.
|
inline |
Lexical cast converts one type to another.
| To | The type to convert to. |
| From | The type to convert from. |
| value | The value to convert. |
| bad_lexical_cast | if the cast was unsuccessful. |
Definition at line 86 of file lexical_cast.hpp.
|
inline |
Lexical cast converts one type to another with a fallback.
| To | The type to convert to. |
| From | The type to convert from. |
| value | The value to convert. |
| fallback | The fallback value to return if the cast fails. |
Definition at line 103 of file lexical_cast.hpp.
Referenced by t_translation::string_to_builder_number_().