0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd: Support explicit float lex_cast.

This commit is contained in:
Jason Volk 2019-10-08 16:59:31 -07:00
parent b82123e09a
commit 8d1f10f8b4
2 changed files with 24 additions and 0 deletions

View file

@ -41,6 +41,7 @@ namespace ircd
template<> bool try_lex_cast<string_view>(const string_view &); // stub always true template<> bool try_lex_cast<string_view>(const string_view &); // stub always true
template<> bool try_lex_cast<long double>(const string_view &); template<> bool try_lex_cast<long double>(const string_view &);
template<> bool try_lex_cast<double>(const string_view &); template<> bool try_lex_cast<double>(const string_view &);
template<> bool try_lex_cast<float>(const string_view &);
template<> bool try_lex_cast<ulong>(const string_view &); template<> bool try_lex_cast<ulong>(const string_view &);
template<> bool try_lex_cast<long>(const string_view &); template<> bool try_lex_cast<long>(const string_view &);
template<> bool try_lex_cast<uint>(const string_view &); template<> bool try_lex_cast<uint>(const string_view &);
@ -61,6 +62,7 @@ namespace ircd
template<> std::string lex_cast(const string_view &); // trivial template<> std::string lex_cast(const string_view &); // trivial
template<> long double lex_cast(const string_view &); template<> long double lex_cast(const string_view &);
template<> double lex_cast(const string_view &); template<> double lex_cast(const string_view &);
template<> float lex_cast(const string_view &);
template<> ulong lex_cast(const string_view &); template<> ulong lex_cast(const string_view &);
template<> long lex_cast(const string_view &); template<> long lex_cast(const string_view &);
template<> uint lex_cast(const string_view &); template<> uint lex_cast(const string_view &);
@ -84,6 +86,7 @@ namespace ircd
template<> string_view lex_cast(nanoseconds, const mutable_buffer &buf); template<> string_view lex_cast(nanoseconds, const mutable_buffer &buf);
template<> string_view lex_cast(long double, const mutable_buffer &buf); template<> string_view lex_cast(long double, const mutable_buffer &buf);
template<> string_view lex_cast(double, const mutable_buffer &buf); template<> string_view lex_cast(double, const mutable_buffer &buf);
template<> string_view lex_cast(float, const mutable_buffer &buf);
template<> string_view lex_cast(ulong, const mutable_buffer &buf); template<> string_view lex_cast(ulong, const mutable_buffer &buf);
template<> string_view lex_cast(long, const mutable_buffer &buf); template<> string_view lex_cast(long, const mutable_buffer &buf);
template<> string_view lex_cast(uint, const mutable_buffer &buf); template<> string_view lex_cast(uint, const mutable_buffer &buf);

View file

@ -168,6 +168,14 @@ ircd::lex_cast(ulong i,
return _lex_cast<MAX>(i, buf); return _lex_cast<MAX>(i, buf);
} }
template<> ircd::string_view
ircd::lex_cast(float i,
const mutable_buffer &buf)
{
static const size_t MAX(64);
return _lex_cast<MAX>(i, buf);
}
template<> ircd::string_view template<> ircd::string_view
ircd::lex_cast(double i, ircd::lex_cast(double i,
const mutable_buffer &buf) const mutable_buffer &buf)
@ -272,6 +280,12 @@ ircd::lex_cast(const string_view &s)
return _lex_cast<unsigned long>(s); return _lex_cast<unsigned long>(s);
} }
template<> float
ircd::lex_cast(const string_view &s)
{
return _lex_cast<float>(s);
}
template<> double template<> double
ircd::lex_cast(const string_view &s) ircd::lex_cast(const string_view &s)
{ {
@ -371,6 +385,13 @@ ircd::try_lex_cast<unsigned long>(const string_view &s)
return boost::conversion::try_lexical_convert(s, i); return boost::conversion::try_lexical_convert(s, i);
} }
template<> bool
ircd::try_lex_cast<float>(const string_view &s)
{
float i;
return boost::conversion::try_lexical_convert(s, i);
}
template<> bool template<> bool
ircd::try_lex_cast<double>(const string_view &s) ircd::try_lex_cast<double>(const string_view &s)
{ {