Checked conversion from any type to an enum, returning an Expected.
Declared in <folly/Conv.h>
template<
class Tgt,
class Src>
Expected<Tgt, ConversionCode>
tryTo(Src const& value) noexcept
requires !std::is_convertible<Src, StringPiece>::value && std::is_enum<Tgt>::value &&
!std::is_same<Src, Tgt>::value;
An Expected holding the converted enum value, or an error code.
| Name | Description |
|---|---|
| value | The value to convert to the enum. |