From: Ronen Friedman Date: Sun, 5 Jan 2020 06:23:58 +0000 (+0200) Subject: crimson: fix non-standard C++ constructs in errorator.h X-Git-Tag: v15.1.0~336^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F32488%2Fhead;p=ceph.git crimson: fix non-standard C++ constructs in errorator.h Fixing use patterns accepted by gcc, but frowned upon by Clang: Put noexcept specifier after attributes specifiers (as per the C++ standard $11.3.5) Limit the use of a not-completely-defined class names to within function bodies, per the standard ("A class is considered a completely-defined object type (or complete type) at the closing } of the class-specifier. Within the class member-specification, the class is regarded as complete within function bodies, default arguments, noexcept-specifiers, and default member initializers (including such things in nested classes). Otherwise it is regarded as incomplete within its own class member-specification.") Signed-off-by: Ronen Friedman --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 1501999e74e..f3911204b41 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -79,8 +79,8 @@ public: template struct unthrowable_wrapper : error_t> { unthrowable_wrapper(const unthrowable_wrapper&) = delete; - static const unthrowable_wrapper instance; [[nodiscard]] static const auto& make() { + static constexpr unthrowable_wrapper instance{}; return instance; } @@ -118,13 +118,11 @@ private: return carrier_instance; } static const auto& from_exception_ptr(std::exception_ptr) { - return instance; + return make(); } friend class error_t>; }; -template -const inline unthrowable_wrapper unthrowable_wrapper::instance{}; template std::exception_ptr unthrowable_wrapper::carrier_instance = \ @@ -481,7 +479,7 @@ private: return this->then_wrapped( [ valfunc = std::forward(valfunc), errfunc = std::forward(errfunc) - ] (auto&& future) mutable [[gnu::always_inline]] noexcept { + ] (auto&& future) mutable noexcept [[gnu::always_inline]] { if (__builtin_expect(future.failed(), false)) { return _safe_then_handle_errors( std::move(future), std::forward(errfunc)); @@ -530,7 +528,7 @@ private: return this->then_wrapped( [ func = std::forward(func) - ] (auto&& future) mutable [[gnu::always_inline]] noexcept { + ] (auto&& future) mutable noexcept [[gnu::always_inline]] { return futurator_t::apply(std::forward(func)).safe_then( [future = std::forward(future)]() mutable { return std::move(future); @@ -574,7 +572,7 @@ private: typename return_errorator_t::template futurize<::seastar::future>; return this->then_wrapped( [ errfunc = std::forward(errfunc) - ] (auto&& future) mutable [[gnu::always_inline]] noexcept { + ] (auto&& future) mutable noexcept [[gnu::always_inline]] { if (__builtin_expect(future.failed(), false)) { return _safe_then_handle_errors( std::move(future), std::forward(errfunc));