]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include: fix build with older clang 23034/head
authorKefu Chai <kchai@redhat.com>
Fri, 13 Jul 2018 16:40:36 +0000 (00:40 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Jul 2018 16:41:24 +0000 (00:41 +0800)
to fix the FTBFS on clang shipped with xcode 9.1 (based on Clang 4.0).

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/convenience.h
src/include/any.h
src/include/denc.h

index 3989c70d1043cca2523f1b5c3850830425574f30..e95fafe849a8fb27516830c1fa6e73f9115950e0 100644 (file)
@@ -14,7 +14,9 @@
 
 #include <mutex>
 #include <memory>
+#if __has_include(<optional>)
 #include <optional>
+#endif
 #include <shared_mutex>
 #include <type_traits>
 #include <utility>
@@ -30,6 +32,7 @@
 #ifndef CEPH_COMMON_CONVENIENCE_H
 #define CEPH_COMMON_CONVENIENCE_H
 
+#if __has_include(<optional>)
 namespace ceph {
 
 // Lock Factories
@@ -147,6 +150,7 @@ inline auto with_shared_lock(Mutex&& mutex, Fun&& fun, Args&&... args)
   return std::forward<Fun>(fun)(std::forward<Args>(args)...);
 }
 }
+#endif // __has_include(<optional>)
 
 // Lock Types
 // ----------
index da59c88f482dcd05365baa936d915ee2703ca7bc..73e729b495b6733bd9d10ed33779784a95af3bf2 100644 (file)
 #ifndef INCLUDE_STATIC_ANY
 #define INCLUDE_STATIC_ANY
 
+#if __has_include(<any>)
 #include <any>
+namespace ceph {
+  using std::bad_any_cast;
+}
+#else
+#include <boost/any.hpp>
+namespace ceph {
+  using boost::bad_any_cast;
+}
+#endif
+
 #include <cstddef>
 #include <initializer_list>
 #include <memory>
@@ -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<T> 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<U, V>& a) {
   if (p) {
     return static_cast<T>(*p);
   }
-  throw std::bad_any_cast();
+  throw ceph::bad_any_cast();
 }
 
 template<typename T, typename U, typename V>
@@ -466,7 +477,7 @@ inline T any_cast(const _any::base<U, V>& a) {
   if (p) {
     return static_cast<T>(*p);
   }
-  throw std::bad_any_cast();
+  throw ceph::bad_any_cast();
 }
 
 template<typename T, typename U, typename V>
@@ -478,7 +489,7 @@ any_cast(_any::base<U, V>&& a) {
   if (p) {
     return std::move((*p));
   }
-  throw std::bad_any_cast();
+  throw ceph::bad_any_cast();
 }
 
 template<typename T, typename U, typename V>
@@ -488,7 +499,7 @@ any_cast(_any::base<U, V>&& a) {
   if (p) {
     return static_cast<T>(*p);
   }
-  throw std::bad_any_cast();
+  throw ceph::bad_any_cast();
 }
 
 // `immobile_any`
index e95c429fb5fac2a8b96876aac28d41c06dbf376a..b0079f2a2325260e86843cf2ec75b70019681ba6 100644 (file)
@@ -27,7 +27,9 @@
 #include <array>
 #include <cstring>
 #include <map>
+#if __has_include(<optional>)
 #include <optional>
+#endif
 #include <set>
 #include <string>
 #include <type_traits>
@@ -1288,6 +1290,7 @@ struct denc_traits<boost::none_t> {
   }
 };
 
+#if __has_include(<optional>)
 //
 // std::optional<T>
 //
@@ -1392,6 +1395,8 @@ struct denc_traits<std::nullopt_t> {
   }
 };
 
+#endif // __has_include(<optional>)
+
 // ----------------------------------------------------------------------
 // class helpers