From 4e5b36305b64ea4cffe7894d256e303f640fac04 Mon Sep 17 00:00:00 2001 From: Sergey Anpilov <anpilov@fb.com> Date: Mon, 12 Feb 2018 03:03:55 -0800 Subject: [PATCH] Make folly.TypeError compatible with -Wdeprecated Summary: Starting with C++11, implicit generation of copy/move constructors/operators in presence of user-defined destructors/constructors/operators is deprecated Reviewed By: yfeldblum Differential Revision: D6875337 fbshipit-source-id: a623a3ce2e7f5559d2de2324565c8995682085c7 --- folly/dynamic-inl.h | 10 ++++++++++ folly/dynamic.cpp | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/folly/dynamic-inl.h b/folly/dynamic-inl.h index 686b446c2..905dc6a56 100644 --- a/folly/dynamic-inl.h +++ b/folly/dynamic-inl.h @@ -82,6 +82,16 @@ 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; }; diff --git a/folly/dynamic.cpp b/folly/dynamic.cpp index dfae4916f..3028eec74 100644 --- a/folly/dynamic.cpp +++ b/folly/dynamic.cpp @@ -60,6 +60,14 @@ 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; [[noreturn]] void throwTypeError_( -- 2.26.2