to overloads
Synopses
Declared in <folly/Conv.h>
Convert a StringPiece to a target type, throwing on failure.
template<class Tgt>
Tgt
to(StringPiece src)
requires !std::is_same<StringPiece, Tgt>::value;
Convert a string by pointer to a target type, updating the pointer.
template<class Tgt>
Tgt
to(StringPiece* src);
Special version of to<SomeString> for floating point. When calling folly::to<SomeString>(double), generic implementation above will firstly reserve 24 (or 25 when negative value) bytes. This will introduce a malloc call for most mainstream string implementations.
template<
class Tgt,
class Src>
Tgt
to(Src value)
requires IsSomeString<Tgt>::value && std::is_floating_point<Src>::value;
Convert a folly string to a target type, throwing on failure.
template<
class Tgt,
class Src>
Tgt
to(Src const& src)
requires IsSomeString<Src>::value && !std::is_same<StringPiece, Tgt>::value;
Unchecked conversion from an arithmetic value to boolean.
template<
class Tgt,
class Src>
Tgt
to(Src const& value)
requires is_arithmetic_v<Src> && !std::is_same<Tgt, Src>::value &&
std::is_same<Tgt, bool>::value;
Convert an enum to another type, throwing on failure.
template<
class Tgt,
class Src>
Tgt
to(Src const& value)
requires std::is_enum<Src>::value && !std::is_same<Src, Tgt>::value &&
!std::is_convertible<Tgt, StringPiece>::value;
Convert any type to an enum, throwing on failure.
template<
class Tgt,
class Src>
Tgt
to(Src const& value)
requires !std::is_convertible<Src, StringPiece>::value && std::is_enum<Tgt>::value &&
!std::is_same<Src, Tgt>::value;
Checked conversion between arithmetic types, throwing on failure.
template<
typename Tgt,
typename Src>
Tgt
to(Src const& value)
requires detail::IsArithToArith<Tgt, Src>::value;
For all chrono conversions, to() wraps tryTo()
template<
typename Tgt,
typename Src>
Tgt
to(Src const& value)
requires detail::is_chrono_conversion<Tgt, Src>::value;
to<SomeString>(v1, v2, ...) uses toAppend() (see below) as back‐end for all types.
template<
class Tgt,
class... Ts>
requires IsSomeString<Tgt>::value &&
(sizeof...(Ts) != 1 ||
!std::is_same<Tgt, detail::LastElement<void, Ts...>>::value)
Tgt
to(Ts const&... vs);
overloadbrief Convert from one type to another.
template<
class Tgt,
class Src>
Tgt
to(Src&& value)
requires std::is_same<Tgt, typename std::decay<Src>::type>::value;
Convert a character range to an integral value, throwing on failure.
template<typename Tgt>
Tgt
to(
char const* b,
char const* e)
requires is_integral_v<Tgt> && !std::is_same<Tgt, bool>::value;
Return Value
-
The converted value.
-
The resulting string.
-
The resulting boolean.
-
The converted enum value.
-
The converted target value, throwing on conversion error.
-
The parsed value.
Parameters
Name |
Description |
src |
The input string to convert. |
value |
The floating‐point value to convert. |
vs |
The values to convert and concatenate. |
b |
Pointer to the first character of the input. |
e |
Pointer past the last character of the input. |
Created with MrDocs