Since they're no longer needed.
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
// backported to C++14.
namespace ceph {
-// Template variable aliases from C++17 <type_traits>
-// primary type categories
-template<class T> constexpr bool is_void_v = std::is_void<T>::value;
-template<class T> constexpr bool is_null_pointer_v =
- std::is_null_pointer<T>::value;
-template<class T> constexpr bool is_integral_v = std::is_integral<T>::value;
-template<class T> constexpr bool is_floating_point_v =
- std::is_floating_point<T>::value;
-template<class T> constexpr bool is_array_v = std::is_array<T>::value;
-template<class T> constexpr bool is_pointer_v = std::is_pointer<T>::value;
-template<class T> constexpr bool is_lvalue_reference_v =
- std::is_lvalue_reference<T>::value;
-template<class T> constexpr bool is_rvalue_reference_v =
- std::is_rvalue_reference<T>::value;
-template<class T> constexpr bool is_member_object_pointer_v =
- std::is_member_object_pointer<T>::value;
-template<class T> constexpr bool is_member_function_pointer_v =
- std::is_member_function_pointer<T>::value;
-template<class T> constexpr bool is_enum_v = std::is_enum<T>::value;
-template<class T> constexpr bool is_union_v = std::is_union<T>::value;
-template<class T> constexpr bool is_class_v = std::is_class<T>::value;
-template<class T> constexpr bool is_function_v = std::is_function<T>::value;
-// composite type categories
-template<class T> constexpr bool is_reference_v = std::is_reference<T>::value;
-template<class T> constexpr bool is_arithmetic_v = std::is_arithmetic<T>::value;
-template<class T> constexpr bool is_fundamental_v =
- std::is_fundamental<T>::value;
-template<class T> constexpr bool is_object_v = std::is_object<T>::value;
-template<class T> constexpr bool is_scalar_v = std::is_scalar<T>::value;
-template<class T> constexpr bool is_compound_v = std::is_compound<T>::value;
-template<class T> constexpr bool is_member_pointer_v =
- std::is_member_pointer<T>::value;
-
-// type properties
-template<class T> constexpr bool is_const_v = std::is_const<T>::value;
-template<class T> constexpr bool is_volatile_v = std::is_volatile<T>::value;
-template<class T> constexpr bool is_trivial_v = std::is_trivial<T>::value;
-template<class T> constexpr bool is_trivially_copyable_v =
- std::is_trivially_copyable<T>::value;
-template<class T> constexpr bool is_standard_layout_v =
- std::is_standard_layout<T>::value;
-template<class T> constexpr bool is_pod_v = std::is_pod<T>::value;
-template<class T> constexpr bool is_empty_v = std::is_empty<T>::value;
-template<class T> constexpr bool is_polymorphic_v =
- std::is_polymorphic<T>::value;
-template<class T> constexpr bool is_abstract_v = std::is_abstract<T>::value;
-template<class T> constexpr bool is_final_v = std::is_final<T>::value;
-template<class T> constexpr bool is_signed_v = std::is_signed<T>::value;
-template<class T> constexpr bool is_unsigned_v = std::is_unsigned<T>::value;
-template<class T, class... Args> constexpr bool is_constructible_v =
- std::is_constructible<T, Args...>::value;
-template<class T> constexpr bool is_default_constructible_v =
- std::is_default_constructible<T>::value;
-template<class T> constexpr bool is_copy_constructible_v =
- std::is_copy_constructible<T>::value;
-template<class T> constexpr bool is_move_constructible_v =
- std::is_move_constructible<T>::value;
-template<class T, class U> constexpr bool is_assignable_v =
- std::is_assignable<T, U>::value;
-template<class T> constexpr bool is_copy_assignable_v =
- std::is_copy_assignable<T>::value;
-template<class T> constexpr bool is_move_assignable_v =
- std::is_move_assignable<T>::value;
-template<class T> constexpr bool is_destructible_v =
- std::is_destructible<T>::value;
-template<class T, class... Args> constexpr bool is_trivially_constructible_v =
- std::is_trivially_constructible<T, Args...>::value;
-template<class T> constexpr bool is_trivially_default_constructible_v =
- std::is_trivially_default_constructible<T>::value;
-template<class T> constexpr bool is_trivially_copy_constructible_v =
- std::is_trivially_copy_constructible<T>::value;
-template<class T> constexpr bool is_trivially_move_constructible_v =
- std::is_trivially_move_constructible<T>::value;
-template<class T, class U> constexpr bool is_trivially_assignable_v =
- std::is_trivially_assignable<T, U>::value;
-template<class T> constexpr bool is_trivially_copy_assignable_v =
- std::is_trivially_copy_assignable<T>::value;
-template<class T> constexpr bool is_trivially_move_assignable_v =
- std::is_trivially_move_assignable<T>::value;
-template<class T> constexpr bool is_trivially_destructible_v =
- std::is_trivially_destructible<T>::value;
-template<class T, class... Args> constexpr bool is_nothrow_constructible_v =
- std::is_nothrow_constructible<T, Args...>::value;
-template<class T> constexpr bool is_nothrow_default_constructible_v =
- std::is_nothrow_default_constructible<T>::value;
-template<class T> constexpr bool is_nothrow_copy_constructible_v =
- std::is_nothrow_copy_constructible<T>::value;
-template<class T> constexpr bool is_nothrow_move_constructible_v =
- std::is_nothrow_move_constructible<T>::value;
-template<class T, class U> constexpr bool is_nothrow_assignable_v =
- std::is_nothrow_assignable<T, U>::value;
-template<class T> constexpr bool is_nothrow_copy_assignable_v =
- std::is_nothrow_copy_assignable<T>::value;
-template<class T> constexpr bool is_nothrow_move_assignable_v =
- std::is_nothrow_move_assignable<T>::value;
-template<class T> constexpr bool is_nothrow_destructible_v =
- std::is_nothrow_destructible<T>::value;
-template<class T> constexpr bool has_virtual_destructor_v =
- std::has_virtual_destructor<T>::value;
-
-// type property queries
-template<class T> constexpr size_t alignment_of_v = std::alignment_of<T>::value;
-template<class T> constexpr size_t rank_v = std::rank<T>::value;
-template<class T, unsigned I = 0> constexpr size_t extent_v =
- std::extent<T, I>::value;
-
-// type relations
-template<class T, class U> constexpr bool is_same_v = std::is_same<T, U>::value;
-template<class Base, class Derived> constexpr bool is_base_of_v =
- std::is_base_of<Base, Derived>::value;
-template<class From, class To> constexpr bool is_convertible_v =
- std::is_convertible<From, To>::value;
namespace _backport17 {
-template <class C>
-constexpr auto size(const C& c) -> decltype(c.size()) {
- return c.size();
-}
-
template <typename T, std::size_t N>
constexpr std::size_t size(const T (&array)[N]) noexcept {
return N;
not_fn_result<F> not_fn(F&& fn) {
return not_fn_result<F>(std::forward<F>(fn));
}
-
-struct in_place_t {};
-constexpr in_place_t in_place{};
-
-template<typename T>
-struct in_place_type_t {};
-
-template<typename T>
-constexpr in_place_type_t<T> in_place_type{};
} // namespace _backport17
namespace _backport_ts {
using _backport17::size;
using _backport17::not_fn;
-using _backport17::in_place_t;
-using _backport17::in_place;
-using _backport17::in_place_type_t;
-using _backport17::in_place_type;
using _backport_ts::ostream_joiner;
using _backport_ts::make_ostream_joiner;
} // namespace ceph
auto maybe_do_or(const boost::optional<T>& t, F&& f, U&& u) ->
std::result_of_t<F(const std::decay_t<T>)>
{
- static_assert(ceph::is_convertible_v<U, std::result_of_t<F(T)>>,
+ static_assert(std::is_convertible_v<U, std::result_of_t<F(T)>>,
"Alternate value must be convertible to function return type.");
if (t)
return std::forward<F>(f)(*t);
//
template<typename T, std::size_t S>
constexpr static int create_ward() noexcept {
- static_assert(ceph::is_void_v<Base> ||
- ceph::is_base_of_v<Base, std::decay_t<T>>,
+ static_assert(std::is_void_v<Base> ||
+ std::is_base_of_v<Base, std::decay_t<T>>,
"Value to store must be a derivative of the base.");
static_assert(S <= Size, "Value too large.");
- static_assert(ceph::is_void_v<Base> || !std::is_const<Base>{} ||
- ceph::is_const_v<T>,
+ static_assert(std::is_void_v<Base> || !std::is_const<Base>{} ||
+ std::is_const_v<T>,
"Cannot assign const pointer to non-const pointer.");
return 0;
}
//
// Since the templated versions don't count for overriding the defaults
static_ptr(const static_ptr& rhs)
- noexcept(ceph::is_nothrow_copy_constructible_v<Base>) : operate(rhs.operate) {
+ noexcept(std::is_nothrow_copy_constructible_v<Base>) : operate(rhs.operate) {
if (operate) {
operate(_mem::op::copy, &rhs.buf, &buf);
}
}
static_ptr(static_ptr&& rhs)
- noexcept(ceph::is_nothrow_move_constructible_v<Base>) : operate(rhs.operate) {
+ noexcept(std::is_nothrow_move_constructible_v<Base>) : operate(rhs.operate) {
if (operate) {
operate(_mem::op::move, &rhs.buf, &buf);
}
template<typename U, std::size_t S>
static_ptr(const static_ptr<U, S>& rhs)
- noexcept(ceph::is_nothrow_copy_constructible_v<U>) : operate(rhs.operate) {
+ noexcept(std::is_nothrow_copy_constructible_v<U>) : operate(rhs.operate) {
create_ward<U, S>();
if (operate) {
operate(_mem::op::copy, &rhs.buf, &buf);
}
template<typename U, std::size_t S>
static_ptr(static_ptr<U, S>&& rhs)
- noexcept(ceph::is_nothrow_move_constructible_v<U>) : operate(rhs.operate) {
+ noexcept(std::is_nothrow_move_constructible_v<U>) : operate(rhs.operate) {
create_ward<U, S>();
if (operate) {
operate(_mem::op::move, &rhs.buf, &buf);
}
static_ptr& operator =(const static_ptr& rhs)
- noexcept(ceph::is_nothrow_copy_constructible_v<Base>) {
+ noexcept(std::is_nothrow_copy_constructible_v<Base>) {
reset();
if (rhs) {
operate = rhs.operate;
return *this;
}
static_ptr& operator =(static_ptr&& rhs)
- noexcept(ceph::is_nothrow_move_constructible_v<Base>) {
+ noexcept(std::is_nothrow_move_constructible_v<Base>) {
reset();
if (rhs) {
operate = rhs.operate;
template<typename U, std::size_t S>
static_ptr& operator =(const static_ptr<U, S>& rhs)
- noexcept(ceph::is_nothrow_copy_constructible_v<U>) {
+ noexcept(std::is_nothrow_copy_constructible_v<U>) {
create_ward<U, S>();
reset();
if (rhs) {
}
template<typename U, std::size_t S>
static_ptr& operator =(static_ptr<U, S>&& rhs)
- noexcept(ceph::is_nothrow_move_constructible_v<U>) {
+ noexcept(std::is_nothrow_move_constructible_v<U>) {
create_ward<U, S>();
reset();
if (rhs) {
// unnecessary. Also it doesn't fit the pointer idiom as well.
//
template<typename T, typename... Args>
- static_ptr(in_place_type_t<T>, Args&& ...args)
- noexcept(ceph::is_nothrow_constructible_v<T, Args...>)
+ static_ptr(std::in_place_type_t<T>, Args&& ...args)
+ noexcept(std::is_nothrow_constructible_v<T, Args...>)
: operate(&_mem::op_fun<T>){
- static_assert((!ceph::is_nothrow_copy_constructible_v<Base> ||
- ceph::is_nothrow_copy_constructible_v<T>) &&
- (!ceph::is_nothrow_move_constructible_v<Base> ||
- ceph::is_nothrow_move_constructible_v<T>),
+ static_assert((!std::is_nothrow_copy_constructible_v<Base> ||
+ std::is_nothrow_copy_constructible_v<T>) &&
+ (!std::is_nothrow_move_constructible_v<Base> ||
+ std::is_nothrow_move_constructible_v<T>),
"If declared type of static_ptr is nothrow "
"move/copy constructible, then any "
"type assigned to it must be as well. "
//
template<typename T, typename... Args>
void emplace(Args&& ...args)
- noexcept(ceph::is_nothrow_constructible_v<T, Args...>) {
+ noexcept(std::is_nothrow_constructible_v<T, Args...>) {
create_ward<T, sizeof(T)>();
reset();
operate = &_mem::op_fun<T>;
return operate ? reinterpret_cast<Base*>(&buf) : nullptr;
}
template<typename U = Base>
- std::enable_if_t<!ceph::is_void_v<U>, Base*> operator->() const noexcept {
+ std::enable_if_t<!std::is_void_v<U>, Base*> operator->() const noexcept {
return get();
}
template<typename U = Base>
- std::enable_if_t<!ceph::is_void_v<U>, Base&> operator *() const noexcept {
+ std::enable_if_t<!std::is_void_v<U>, Base&> operator *() const noexcept {
return *get();
}
operator bool() const noexcept {
// returns a null value rather than throwing.
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> resize_pointer_cast(const static_ptr<T, S>& p) {
- static_assert(ceph::is_same_v<U, T>,
+ static_assert(std::is_same_v<U, T>,
"resize_pointer_cast only changes size, not type.");
static_ptr<U, Z> r;
if (Z >= p.operate(_mem::op::size, &p.buf, nullptr)) {
}
template<typename U, std::size_t Z, typename T, std::size_t S>
static_ptr<U, Z> resize_pointer_cast(static_ptr<T, S>&& p) {
- static_assert(ceph::is_same_v<U, T>,
+ static_assert(std::is_same_v<U, T>,
"resize_pointer_cast only changes size, not type.");
static_ptr<U, Z> r;
if (Z >= p.operate(_mem::op::size, &p.buf, nullptr)) {
template<typename Base, typename Derived = Base,
std::size_t Size = sizeof(Derived), typename... Args>
static_ptr<Base, Size> make_static(Args&& ...args) {
- return { ceph::in_place_type<Derived>, std::forward<Args>(args)... };
+ return { std::in_place_type<Derived>, std::forward<Args>(args)... };
}
}
scope_guard(const F& f) : f(f) {}
scope_guard(F &&f) : f(std::move(f)) {}
template<typename... Args>
- scope_guard(ceph::in_place_t, Args&& ...args) : f(std::forward<Args>(args)...) {}
+ scope_guard(std::in_place_t, Args&& ...args) : f(std::forward<Args>(args)...) {}
~scope_guard() {
std::move(f)(); // Support at-most-once functions
}
}
template<typename F, typename... Args>
-scope_guard<F> make_scope_guard(ceph::in_place_type_t<F>, Args&& ...args) {
- return { ceph::in_place, std::forward<Args>(args)... };
+scope_guard<F> make_scope_guard(std::in_place_type_t<F>, Args&& ...args) {
+ return { std::in_place, std::forward<Args>(args)... };
}
#endif
TEST(StaticPtr, CreationCall) {
{
- static_ptr<base, sizeof(grandchild)> p(ceph::in_place_type_t<sibling1>{});
+ static_ptr<base, sizeof(grandchild)> p(std::in_place_type_t<sibling1>{});
EXPECT_TRUE(p);
EXPECT_FALSE(p == nullptr);
EXPECT_FALSE(nullptr == p);
TEST(StaticPtr, CreateReset) {
{
- static_ptr<base, sizeof(grandchild)> p(ceph::in_place_type_t<sibling1>{});
+ static_ptr<base, sizeof(grandchild)> p(std::in_place_type_t<sibling1>{});
EXPECT_EQ((p.get())->func(), 0);
p.reset();
EXPECT_FALSE(p);
EXPECT_TRUE(p.get() == nullptr);
}
{
- static_ptr<base, sizeof(grandchild)> p(ceph::in_place_type_t<sibling1>{});
+ static_ptr<base, sizeof(grandchild)> p(std::in_place_type_t<sibling1>{});
EXPECT_EQ((p.get())->func(), 0);
p = nullptr;
EXPECT_FALSE(p);
}
TEST(StaticPtr, CreateEmplace) {
- static_ptr<base, sizeof(grandchild)> p(ceph::in_place_type_t<sibling1>{});
+ static_ptr<base, sizeof(grandchild)> p(std::in_place_type_t<sibling1>{});
EXPECT_EQ((p.get())->func(), 0);
p.emplace<grandchild>(30);
EXPECT_EQ(p->func(), 9);
TEST(StaticPtr, CopyMove) {
// Won't compile. Good.
- // static_ptr<base, sizeof(base)> p1(ceph::in_place_type_t<grandchild>{}, 3);
+ // static_ptr<base, sizeof(base)> p1(std::in_place_type_t<grandchild>{}, 3);
- static_ptr<base, sizeof(base)> p1(ceph::in_place_type_t<sibling1>{});
- static_ptr<base, sizeof(grandchild)> p2(ceph::in_place_type_t<grandchild>{},
+ static_ptr<base, sizeof(base)> p1(std::in_place_type_t<sibling1>{});
+ static_ptr<base, sizeof(grandchild)> p2(std::in_place_type_t<grandchild>{},
3);
// This also does not compile. Good.
TEST(StaticPtr, ImplicitUpcast) {
static_ptr<base, sizeof(grandchild)> p1;
- static_ptr<sibling2, sizeof(grandchild)> p2(ceph::in_place_type_t<grandchild>{}, 3);
+ static_ptr<sibling2, sizeof(grandchild)> p2(std::in_place_type_t<grandchild>{}, 3);
p1 = p2;
EXPECT_EQ(p1->func(), 9);
}
TEST(StaticPtr, StaticCast) {
- static_ptr<base, sizeof(grandchild)> p1(ceph::in_place_type_t<grandchild>{}, 3);
+ static_ptr<base, sizeof(grandchild)> p1(std::in_place_type_t<grandchild>{}, 3);
static_ptr<sibling2, sizeof(grandchild)> p2;
p2 = ceph::static_pointer_cast<sibling2, sizeof(grandchild)>(p1);
TEST(StaticPtr, DynamicCast) {
static constexpr auto sz = sizeof(great_grandchild);
{
- static_ptr<base, sz> p1(ceph::in_place_type_t<grandchild>{}, 3);
+ static_ptr<base, sz> p1(std::in_place_type_t<grandchild>{}, 3);
auto p2 = ceph::dynamic_pointer_cast<great_grandchild, sz>(p1);
EXPECT_FALSE(p2);
}
{
- static_ptr<base, sz> p1(ceph::in_place_type_t<grandchild>{}, 3);
+ static_ptr<base, sz> p1(std::in_place_type_t<grandchild>{}, 3);
auto p2 = ceph::dynamic_pointer_cast<great_grandchild, sz>(std::move(p1));
EXPECT_FALSE(p2);
}
{
- static_ptr<base, sz> p1(ceph::in_place_type_t<grandchild>{}, 3);
+ static_ptr<base, sz> p1(std::in_place_type_t<grandchild>{}, 3);
auto p2 = ceph::dynamic_pointer_cast<grandchild, sz>(p1);
EXPECT_TRUE(p2);
EXPECT_EQ(p2->func(), 9);
EXPECT_EQ(p2->call(10), 30);
}
{
- static_ptr<base, sz> p1(ceph::in_place_type_t<grandchild>{}, 3);
+ static_ptr<base, sz> p1(std::in_place_type_t<grandchild>{}, 3);
auto p2 = ceph::dynamic_pointer_cast<grandchild, sz>(std::move(p1));
EXPECT_TRUE(p2);
EXPECT_EQ(p2->func(), 9);
};
TEST(StaticPtr, Exceptional) {
- static_ptr<exceptional> p1(ceph::in_place_type_t<exceptional>{});
+ static_ptr<exceptional> p1(std::in_place_type_t<exceptional>{});
EXPECT_ANY_THROW(static_ptr<exceptional> p2(p1));
EXPECT_ANY_THROW(static_ptr<exceptional> p2(std::move(p1)));
}