From: Kefu Chai Date: Fri, 13 Jul 2018 16:40:36 +0000 (+0800) Subject: include: fix build with older clang X-Git-Tag: v13.2.1~61^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F23034%2Fhead;p=ceph.git include: fix build with older clang to fix the FTBFS on clang shipped with xcode 9.1 (based on Clang 4.0). Signed-off-by: Kefu Chai --- diff --git a/src/common/convenience.h b/src/common/convenience.h index 3989c70d1043..e95fafe849a8 100644 --- a/src/common/convenience.h +++ b/src/common/convenience.h @@ -14,7 +14,9 @@ #include #include +#if __has_include() #include +#endif #include #include #include @@ -30,6 +32,7 @@ #ifndef CEPH_COMMON_CONVENIENCE_H #define CEPH_COMMON_CONVENIENCE_H +#if __has_include() namespace ceph { // Lock Factories @@ -147,6 +150,7 @@ inline auto with_shared_lock(Mutex&& mutex, Fun&& fun, Args&&... args) return std::forward(fun)(std::forward(args)...); } } +#endif // __has_include() // Lock Types // ---------- diff --git a/src/include/any.h b/src/include/any.h index da59c88f482d..73e729b495b6 100644 --- a/src/include/any.h +++ b/src/include/any.h @@ -15,7 +15,18 @@ #ifndef INCLUDE_STATIC_ANY #define INCLUDE_STATIC_ANY +#if __has_include() #include +namespace ceph { + using std::bad_any_cast; +} +#else +#include +namespace ceph { + using boost::bad_any_cast; +} +#endif + #include #include #include @@ -298,7 +309,7 @@ public: // only stores the decayed type. I suspect this was to get around // the question of whether, for a std::any holding a T&, // std::any_cast should return a copy or throw - // std::bad_any_cast. + // ceph::bad_any_cast. // // I think the appropriate response in that case would be to make a // copy if the type supports it and fail otherwise. Once a concrete @@ -453,7 +464,7 @@ inline T any_cast(_any::base& a) { if (p) { return static_cast(*p); } - throw std::bad_any_cast(); + throw ceph::bad_any_cast(); } template @@ -466,7 +477,7 @@ inline T any_cast(const _any::base& a) { if (p) { return static_cast(*p); } - throw std::bad_any_cast(); + throw ceph::bad_any_cast(); } template @@ -478,7 +489,7 @@ any_cast(_any::base&& a) { if (p) { return std::move((*p)); } - throw std::bad_any_cast(); + throw ceph::bad_any_cast(); } template @@ -488,7 +499,7 @@ any_cast(_any::base&& a) { if (p) { return static_cast(*p); } - throw std::bad_any_cast(); + throw ceph::bad_any_cast(); } // `immobile_any` diff --git a/src/include/denc.h b/src/include/denc.h index e95c429fb5fa..b0079f2a2325 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -27,7 +27,9 @@ #include #include #include +#if __has_include() #include +#endif #include #include #include @@ -1288,6 +1290,7 @@ struct denc_traits { } }; +#if __has_include() // // std::optional // @@ -1392,6 +1395,8 @@ struct denc_traits { } }; +#endif // __has_include() + // ---------------------------------------------------------------------- // class helpers