Commit baeb381c authored by Joe Loser's avatar Joe Loser Committed by Facebook Github Bot

Inline TypeError special member functions (#1034)

Summary:
The `TypeError` special member functions - copy and move constructors and assignment operators - were outlined to reduce inline code size of `throw TypeError(...);` statements. This is no longer necessary, since these sites have been replaced by `folly::throw_exception<TypeError>(...);` statements, which have minimal inline code size. As a benefit, the special member functions may all now be declared as defaulted within the class body, and the conditional `noexcept` calculations are no longer required to be written - the compiler will do them. (Note: as of the libstdc++ which ships with GCC 5, library exception special member functions are `noexcept`; previously, they are not.)

Pull Request resolved: https://github.com/facebook/folly/pull/1034

Reviewed By: nbronson

Differential Revision: D14255166

Pulled By: yfeldblum

fbshipit-source-id: 2f795a2b937fee58f243a9d374fc01829c674fe6
parent 61c3151a
......@@ -134,17 +134,6 @@ struct FOLLY_EXPORT TypeError : std::runtime_error {
const std::string& expected,
dynamic::Type actual1,
dynamic::Type actual2);
// TODO: noexcept calculation required through gcc-v4.9; remove once upgrading
// to gcc-v5.
TypeError(const TypeError&) noexcept(
std::is_nothrow_copy_constructible<std::runtime_error>::value);
TypeError& operator=(const TypeError&) noexcept(
std::is_nothrow_copy_assignable<std::runtime_error>::value);
TypeError(TypeError&&) noexcept(
std::is_nothrow_move_constructible<std::runtime_error>::value);
TypeError& operator=(TypeError&&) noexcept(
std::is_nothrow_move_assignable<std::runtime_error>::value);
~TypeError() override;
};
//////////////////////////////////////////////////////////////////////
......
......@@ -63,16 +63,6 @@ TypeError::TypeError(
dynamic::typeName(actual1),
dynamic::typeName(actual2))) {}
TypeError::TypeError(const TypeError&) noexcept(
std::is_nothrow_copy_constructible<std::runtime_error>::value) = default;
TypeError& TypeError::operator=(const TypeError&) noexcept(
std::is_nothrow_copy_assignable<std::runtime_error>::value) = default;
TypeError::TypeError(TypeError&&) noexcept(
std::is_nothrow_move_constructible<std::runtime_error>::value) = default;
TypeError& TypeError::operator=(TypeError&&) noexcept(
std::is_nothrow_move_assignable<std::runtime_error>::value) = default;
TypeError::~TypeError() = default;
// This is a higher-order preprocessor macro to aid going from runtime
// types to the compile time type system.
#define FB_DYNAMIC_APPLY(type, apply) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment