]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: fix non-standard C++ constructs in errorator.h 32488/head
authorRonen Friedman <rfriedma@redhat.com>
Sun, 5 Jan 2020 06:23:58 +0000 (08:23 +0200)
committerRonen Friedman <rfriedma@redhat.com>
Sun, 5 Jan 2020 17:50:52 +0000 (19:50 +0200)
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 <rfriedma@redhat.com>
src/crimson/common/errorator.h

index 1501999e74ed83edb3e32e20081bde30140a9b2d..f3911204b41cb8c22f3d17710312a1b6b7f2ffec 100644 (file)
@@ -79,8 +79,8 @@ public:
 template <class ErrorT, ErrorT ErrorV>
 struct unthrowable_wrapper : error_t<unthrowable_wrapper<ErrorT, ErrorV>> {
   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<unthrowable_wrapper<ErrorT, ErrorV>>;
 };
-template <class ErrorT, ErrorT ErrorV>
-const inline unthrowable_wrapper<ErrorT, ErrorV> unthrowable_wrapper<ErrorT, ErrorV>::instance{};
 
 template <class ErrorT, ErrorT ErrorV>
 std::exception_ptr unthrowable_wrapper<ErrorT, ErrorV>::carrier_instance = \
@@ -481,7 +479,7 @@ private:
       return this->then_wrapped(
         [ valfunc = std::forward<ValueFuncT>(valfunc),
           errfunc = std::forward<ErrorVisitorT>(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<futurator_t>(
               std::move(future), std::forward<ErrorVisitorT>(errfunc));
@@ -530,7 +528,7 @@ private:
 
       return this->then_wrapped(
        [ func = std::forward<FuncT>(func)
-       ] (auto&& future) mutable [[gnu::always_inline]] noexcept {
+       ] (auto&& future) mutable noexcept [[gnu::always_inline]] {
          return futurator_t::apply(std::forward<FuncT>(func)).safe_then(
            [future = std::forward<decltype(future)>(future)]() mutable {
              return std::move(future);
@@ -574,7 +572,7 @@ private:
         typename return_errorator_t::template futurize<::seastar::future<ValuesT...>>;
       return this->then_wrapped(
         [ errfunc = std::forward<ErrorVisitorT>(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<futurator_t>(
               std::move(future), std::forward<ErrorVisitorT>(errfunc));