#include <mutex>
#include <memory>
+#if __has_include(<optional>)
#include <optional>
+#endif
#include <shared_mutex>
#include <type_traits>
#include <utility>
#ifndef CEPH_COMMON_CONVENIENCE_H
#define CEPH_COMMON_CONVENIENCE_H
+#if __has_include(<optional>)
namespace ceph {
// Lock Factories
return std::forward<Fun>(fun)(std::forward<Args>(args)...);
}
}
+#endif // __has_include(<optional>)
// Lock Types
// ----------
#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>
// 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
if (p) {
return static_cast<T>(*p);
}
- throw std::bad_any_cast();
+ throw ceph::bad_any_cast();
}
template<typename T, typename U, typename V>
if (p) {
return static_cast<T>(*p);
}
- throw std::bad_any_cast();
+ throw ceph::bad_any_cast();
}
template<typename T, typename U, typename V>
if (p) {
return std::move((*p));
}
- throw std::bad_any_cast();
+ throw ceph::bad_any_cast();
}
template<typename T, typename U, typename V>
if (p) {
return static_cast<T>(*p);
}
- throw std::bad_any_cast();
+ throw ceph::bad_any_cast();
}
// `immobile_any`