folly::FutureException inherits from std::logic_error, like std::future_error; becomes smaller and nothrow-copy
Summary:
folly::FutureException was inheriting from std::exception and managing its own message in a std::string data member.
That is suboptimal for the following reasons:
1) The analagous std:: type, std::future_error, inherits from std::logic_error. According to the Principle of Least
Astonishment, folly::FutureExpception should follow suit.
2) std::logic_error has a nothrow copy constructor. (This is typically implemented with a ref-counted string.)
std::string does not. By explicitly managing its own message, folly::FutureException picks up a throwing copy
constructor. Exception classes should try to be nothrow copyable.
3) With most stdlib implementations, std::string is larger by a lot than the std:: exceptions. By changing
folly::FutureException as suggested, its size drops from 40 bytes to 16 on clang and gcc >=5.0.
Also, I took the liberty of fixing some copy-pastas that gave some of these exception types explicit default
constructors.
Reviewed By: yfeldblum
Differential Revision:
D4367909
fbshipit-source-id:
1639d404237493f929db6116a760c2d0e599877d