Use folly::Expected to implement folly::tryTo, a non-throwing variant of folly::to
Summary:
This change adds a non-throwing interface for folly::to<T>: tryTo<T>, which
returns an Expected<T, ConversionCode>.
Here is how the non-throwing interface compares to the regular interface in
terms of performance. On the successful path, there's generally not much
difference between using the throwing and non-throwing interfaces. For the
error path, tryTo<> is about three orders of magnitude faster than to<>.
Reviewed By: mhx
Differential Revision:
D3720512
fbshipit-source-id:
dadb8db1b7d7ad8d3e80c1cc69c0480169f9217a