to overloads
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;
» more...
Convert a string by pointer to a target type, updating the pointer.
template<class Tgt>
Tgt
to(StringPiece* src);
» more...
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;
» more...
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;
» more...
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;
» more...
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;
» more...
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;
» more...
Checked conversion between arithmetic types, throwing on failure.
template<
typename Tgt,
typename Src>
Tgt
to(Src const& value)
requires detail::IsArithToArith<Tgt, Src>::value;
» more...
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;
» more...
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);
» more...
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;
» more...
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;
» more...
| 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. |