3#include "../concepts.hpp"
6#define GZ_UTIL_STRING_CONCEPTS
13template<gz::util::False T>
18 concept ConstructibleFromStringGlobal =
requires(
const std::string& s) {
19 { ::fromString<T>(s) } -> std::same_as<T>;
27 std::same_as<T, int> or
28 std::same_as<T, long> or
29 std::same_as<T, long long> or
30 std::same_as<T, unsigned int> or
31 std::same_as<T, unsigned long> or
32 std::same_as<T, unsigned long long> or
33 std::same_as<T, float> or
34 std::same_as<T, double> or
35 std::same_as<T, long double> or
36 std::same_as<T, bool>;
50 template<util::GetTypeFromStringImplemented T>
54 template<>
inline int fromString<int>(
const std::string& s) {
58 template<>
inline long fromString<long>(
const std::string& s) {
62 template<>
inline long long fromString<long long>(
const std::string& s) {
66 template<>
inline unsigned int fromString<unsigned int>(
const std::string& s) {
70 template<>
inline unsigned long fromString<unsigned long>(
const std::string& s) {
74 template<>
inline unsigned long long fromString<unsigned long long>(
const std::string& s) {
75 return std::stoull(s);
78 template<>
inline float fromString<float>(
const std::string& s) {
82 template<>
inline double fromString<double>(
const std::string& s) {
86 template<>
inline long double fromString<long double>(
const std::string& s) {
96 template<>
bool fromString<bool>(
const std::string& s);
102 template<util::ConstructibleFromStringGlobal T>
104 return ::fromString<T>(s);
115 { fromString<T>(s) } -> std::same_as<T>;
Any type where fromString(string) exists and returns T.
Definition: from_string.hpp:114
toString is implemented for these types
Definition: from_string.hpp:26
T fromString(const std::string &s)
Declaration of fromString in global namespace, so that concepts can use it.