From: Adam C. Emerson Date: Fri, 22 Dec 2017 21:41:58 +0000 (-0500) Subject: common: Remove backported typedefs X-Git-Tag: v13.0.2~610^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad038df0fddb7a0a5931e3dec9ec7c890aac8c2e;p=ceph.git common: Remove backported typedefs Since they're no longer needed. Signed-off-by: Adam C. Emerson --- diff --git a/src/common/backport_std.h b/src/common/backport_std.h index 880b103deb8c..e6b0c700c8d4 100644 --- a/src/common/backport_std.h +++ b/src/common/backport_std.h @@ -22,125 +22,8 @@ // backported to C++14. namespace ceph { -// Template variable aliases from C++17 -// primary type categories -template constexpr bool is_void_v = std::is_void::value; -template constexpr bool is_null_pointer_v = - std::is_null_pointer::value; -template constexpr bool is_integral_v = std::is_integral::value; -template constexpr bool is_floating_point_v = - std::is_floating_point::value; -template constexpr bool is_array_v = std::is_array::value; -template constexpr bool is_pointer_v = std::is_pointer::value; -template constexpr bool is_lvalue_reference_v = - std::is_lvalue_reference::value; -template constexpr bool is_rvalue_reference_v = - std::is_rvalue_reference::value; -template constexpr bool is_member_object_pointer_v = - std::is_member_object_pointer::value; -template constexpr bool is_member_function_pointer_v = - std::is_member_function_pointer::value; -template constexpr bool is_enum_v = std::is_enum::value; -template constexpr bool is_union_v = std::is_union::value; -template constexpr bool is_class_v = std::is_class::value; -template constexpr bool is_function_v = std::is_function::value; -// composite type categories -template constexpr bool is_reference_v = std::is_reference::value; -template constexpr bool is_arithmetic_v = std::is_arithmetic::value; -template constexpr bool is_fundamental_v = - std::is_fundamental::value; -template constexpr bool is_object_v = std::is_object::value; -template constexpr bool is_scalar_v = std::is_scalar::value; -template constexpr bool is_compound_v = std::is_compound::value; -template constexpr bool is_member_pointer_v = - std::is_member_pointer::value; - -// type properties -template constexpr bool is_const_v = std::is_const::value; -template constexpr bool is_volatile_v = std::is_volatile::value; -template constexpr bool is_trivial_v = std::is_trivial::value; -template constexpr bool is_trivially_copyable_v = - std::is_trivially_copyable::value; -template constexpr bool is_standard_layout_v = - std::is_standard_layout::value; -template constexpr bool is_pod_v = std::is_pod::value; -template constexpr bool is_empty_v = std::is_empty::value; -template constexpr bool is_polymorphic_v = - std::is_polymorphic::value; -template constexpr bool is_abstract_v = std::is_abstract::value; -template constexpr bool is_final_v = std::is_final::value; -template constexpr bool is_signed_v = std::is_signed::value; -template constexpr bool is_unsigned_v = std::is_unsigned::value; -template constexpr bool is_constructible_v = - std::is_constructible::value; -template constexpr bool is_default_constructible_v = - std::is_default_constructible::value; -template constexpr bool is_copy_constructible_v = - std::is_copy_constructible::value; -template constexpr bool is_move_constructible_v = - std::is_move_constructible::value; -template constexpr bool is_assignable_v = - std::is_assignable::value; -template constexpr bool is_copy_assignable_v = - std::is_copy_assignable::value; -template constexpr bool is_move_assignable_v = - std::is_move_assignable::value; -template constexpr bool is_destructible_v = - std::is_destructible::value; -template constexpr bool is_trivially_constructible_v = - std::is_trivially_constructible::value; -template constexpr bool is_trivially_default_constructible_v = - std::is_trivially_default_constructible::value; -template constexpr bool is_trivially_copy_constructible_v = - std::is_trivially_copy_constructible::value; -template constexpr bool is_trivially_move_constructible_v = - std::is_trivially_move_constructible::value; -template constexpr bool is_trivially_assignable_v = - std::is_trivially_assignable::value; -template constexpr bool is_trivially_copy_assignable_v = - std::is_trivially_copy_assignable::value; -template constexpr bool is_trivially_move_assignable_v = - std::is_trivially_move_assignable::value; -template constexpr bool is_trivially_destructible_v = - std::is_trivially_destructible::value; -template constexpr bool is_nothrow_constructible_v = - std::is_nothrow_constructible::value; -template constexpr bool is_nothrow_default_constructible_v = - std::is_nothrow_default_constructible::value; -template constexpr bool is_nothrow_copy_constructible_v = - std::is_nothrow_copy_constructible::value; -template constexpr bool is_nothrow_move_constructible_v = - std::is_nothrow_move_constructible::value; -template constexpr bool is_nothrow_assignable_v = - std::is_nothrow_assignable::value; -template constexpr bool is_nothrow_copy_assignable_v = - std::is_nothrow_copy_assignable::value; -template constexpr bool is_nothrow_move_assignable_v = - std::is_nothrow_move_assignable::value; -template constexpr bool is_nothrow_destructible_v = - std::is_nothrow_destructible::value; -template constexpr bool has_virtual_destructor_v = - std::has_virtual_destructor::value; - -// type property queries -template constexpr size_t alignment_of_v = std::alignment_of::value; -template constexpr size_t rank_v = std::rank::value; -template constexpr size_t extent_v = - std::extent::value; - -// type relations -template constexpr bool is_same_v = std::is_same::value; -template constexpr bool is_base_of_v = - std::is_base_of::value; -template constexpr bool is_convertible_v = - std::is_convertible::value; namespace _backport17 { -template -constexpr auto size(const C& c) -> decltype(c.size()) { - return c.size(); -} - template constexpr std::size_t size(const T (&array)[N]) noexcept { return N; @@ -185,15 +68,6 @@ template not_fn_result not_fn(F&& fn) { return not_fn_result(std::forward(fn)); } - -struct in_place_t {}; -constexpr in_place_t in_place{}; - -template -struct in_place_type_t {}; - -template -constexpr in_place_type_t in_place_type{}; } // namespace _backport17 namespace _backport_ts { @@ -259,10 +133,6 @@ make_ostream_joiner(std::basic_ostream& os, 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 diff --git a/src/common/convenience.h b/src/common/convenience.h index 66baf562d292..49a74a3b3ae1 100644 --- a/src/common/convenience.h +++ b/src/common/convenience.h @@ -192,7 +192,7 @@ template auto maybe_do_or(const boost::optional& t, F&& f, U&& u) -> std::result_of_t)> { - static_assert(ceph::is_convertible_v>, + static_assert(std::is_convertible_v>, "Alternate value must be convertible to function return type."); if (t) return std::forward(f)(*t); diff --git a/src/common/static_ptr.h b/src/common/static_ptr.h index fd8b0e07f07d..54542ab2ffdf 100644 --- a/src/common/static_ptr.h +++ b/src/common/static_ptr.h @@ -86,12 +86,12 @@ class static_ptr { // template constexpr static int create_ward() noexcept { - static_assert(ceph::is_void_v || - ceph::is_base_of_v>, + static_assert(std::is_void_v || + std::is_base_of_v>, "Value to store must be a derivative of the base."); static_assert(S <= Size, "Value too large."); - static_assert(ceph::is_void_v || !std::is_const{} || - ceph::is_const_v, + static_assert(std::is_void_v || !std::is_const{} || + std::is_const_v, "Cannot assign const pointer to non-const pointer."); return 0; } @@ -135,13 +135,13 @@ public: // // Since the templated versions don't count for overriding the defaults static_ptr(const static_ptr& rhs) - noexcept(ceph::is_nothrow_copy_constructible_v) : operate(rhs.operate) { + noexcept(std::is_nothrow_copy_constructible_v) : operate(rhs.operate) { if (operate) { operate(_mem::op::copy, &rhs.buf, &buf); } } static_ptr(static_ptr&& rhs) - noexcept(ceph::is_nothrow_move_constructible_v) : operate(rhs.operate) { + noexcept(std::is_nothrow_move_constructible_v) : operate(rhs.operate) { if (operate) { operate(_mem::op::move, &rhs.buf, &buf); } @@ -149,7 +149,7 @@ public: template static_ptr(const static_ptr& rhs) - noexcept(ceph::is_nothrow_copy_constructible_v) : operate(rhs.operate) { + noexcept(std::is_nothrow_copy_constructible_v) : operate(rhs.operate) { create_ward(); if (operate) { operate(_mem::op::copy, &rhs.buf, &buf); @@ -157,7 +157,7 @@ public: } template static_ptr(static_ptr&& rhs) - noexcept(ceph::is_nothrow_move_constructible_v) : operate(rhs.operate) { + noexcept(std::is_nothrow_move_constructible_v) : operate(rhs.operate) { create_ward(); if (operate) { operate(_mem::op::move, &rhs.buf, &buf); @@ -165,7 +165,7 @@ public: } static_ptr& operator =(const static_ptr& rhs) - noexcept(ceph::is_nothrow_copy_constructible_v) { + noexcept(std::is_nothrow_copy_constructible_v) { reset(); if (rhs) { operate = rhs.operate; @@ -175,7 +175,7 @@ public: return *this; } static_ptr& operator =(static_ptr&& rhs) - noexcept(ceph::is_nothrow_move_constructible_v) { + noexcept(std::is_nothrow_move_constructible_v) { reset(); if (rhs) { operate = rhs.operate; @@ -186,7 +186,7 @@ public: template static_ptr& operator =(const static_ptr& rhs) - noexcept(ceph::is_nothrow_copy_constructible_v) { + noexcept(std::is_nothrow_copy_constructible_v) { create_ward(); reset(); if (rhs) { @@ -198,7 +198,7 @@ public: } template static_ptr& operator =(static_ptr&& rhs) - noexcept(ceph::is_nothrow_move_constructible_v) { + noexcept(std::is_nothrow_move_constructible_v) { create_ward(); reset(); if (rhs) { @@ -215,13 +215,13 @@ public: // unnecessary. Also it doesn't fit the pointer idiom as well. // template - static_ptr(in_place_type_t, Args&& ...args) - noexcept(ceph::is_nothrow_constructible_v) + static_ptr(std::in_place_type_t, Args&& ...args) + noexcept(std::is_nothrow_constructible_v) : operate(&_mem::op_fun){ - static_assert((!ceph::is_nothrow_copy_constructible_v || - ceph::is_nothrow_copy_constructible_v) && - (!ceph::is_nothrow_move_constructible_v || - ceph::is_nothrow_move_constructible_v), + static_assert((!std::is_nothrow_copy_constructible_v || + std::is_nothrow_copy_constructible_v) && + (!std::is_nothrow_move_constructible_v || + std::is_nothrow_move_constructible_v), "If declared type of static_ptr is nothrow " "move/copy constructible, then any " "type assigned to it must be as well. " @@ -239,7 +239,7 @@ public: // template void emplace(Args&& ...args) - noexcept(ceph::is_nothrow_constructible_v) { + noexcept(std::is_nothrow_constructible_v) { create_ward(); reset(); operate = &_mem::op_fun; @@ -251,11 +251,11 @@ public: return operate ? reinterpret_cast(&buf) : nullptr; } template - std::enable_if_t, Base*> operator->() const noexcept { + std::enable_if_t, Base*> operator->() const noexcept { return get(); } template - std::enable_if_t, Base&> operator *() const noexcept { + std::enable_if_t, Base&> operator *() const noexcept { return *get(); } operator bool() const noexcept { @@ -402,7 +402,7 @@ static_ptr reinterpret_pointer_cast(static_ptr&& p) { // returns a null value rather than throwing. template static_ptr resize_pointer_cast(const static_ptr& p) { - static_assert(ceph::is_same_v, + static_assert(std::is_same_v, "resize_pointer_cast only changes size, not type."); static_ptr r; if (Z >= p.operate(_mem::op::size, &p.buf, nullptr)) { @@ -413,7 +413,7 @@ static_ptr resize_pointer_cast(const static_ptr& p) { } template static_ptr resize_pointer_cast(static_ptr&& p) { - static_assert(ceph::is_same_v, + static_assert(std::is_same_v, "resize_pointer_cast only changes size, not type."); static_ptr r; if (Z >= p.operate(_mem::op::size, &p.buf, nullptr)) { @@ -438,6 +438,6 @@ bool operator ==(std::nullptr_t, static_ptr s) { template static_ptr make_static(Args&& ...args) { - return { ceph::in_place_type, std::forward(args)... }; + return { std::in_place_type, std::forward(args)... }; } } diff --git a/src/include/scope_guard.h b/src/include/scope_guard.h index 2c11d89f82d5..b3eb3fd54700 100644 --- a/src/include/scope_guard.h +++ b/src/include/scope_guard.h @@ -30,7 +30,7 @@ struct scope_guard { scope_guard(const F& f) : f(f) {} scope_guard(F &&f) : f(std::move(f)) {} template - scope_guard(ceph::in_place_t, Args&& ...args) : f(std::forward(args)...) {} + scope_guard(std::in_place_t, Args&& ...args) : f(std::forward(args)...) {} ~scope_guard() { std::move(f)(); // Support at-most-once functions } @@ -42,8 +42,8 @@ scope_guard make_scope_guard(F &&f) { } template -scope_guard make_scope_guard(ceph::in_place_type_t, Args&& ...args) { - return { ceph::in_place, std::forward(args)... }; +scope_guard make_scope_guard(std::in_place_type_t, Args&& ...args) { + return { std::in_place, std::forward(args)... }; } #endif diff --git a/src/test/common/test_static_ptr.cc b/src/test/common/test_static_ptr.cc index 4a464d79f548..bfa5733d8179 100644 --- a/src/test/common/test_static_ptr.cc +++ b/src/test/common/test_static_ptr.cc @@ -59,7 +59,7 @@ TEST(StaticPtr, EmptyCreation) { TEST(StaticPtr, CreationCall) { { - static_ptr p(ceph::in_place_type_t{}); + static_ptr p(std::in_place_type_t{}); EXPECT_TRUE(p); EXPECT_FALSE(p == nullptr); EXPECT_FALSE(nullptr == p); @@ -82,7 +82,7 @@ TEST(StaticPtr, CreationCall) { TEST(StaticPtr, CreateReset) { { - static_ptr p(ceph::in_place_type_t{}); + static_ptr p(std::in_place_type_t{}); EXPECT_EQ((p.get())->func(), 0); p.reset(); EXPECT_FALSE(p); @@ -91,7 +91,7 @@ TEST(StaticPtr, CreateReset) { EXPECT_TRUE(p.get() == nullptr); } { - static_ptr p(ceph::in_place_type_t{}); + static_ptr p(std::in_place_type_t{}); EXPECT_EQ((p.get())->func(), 0); p = nullptr; EXPECT_FALSE(p); @@ -102,7 +102,7 @@ TEST(StaticPtr, CreateReset) { } TEST(StaticPtr, CreateEmplace) { - static_ptr p(ceph::in_place_type_t{}); + static_ptr p(std::in_place_type_t{}); EXPECT_EQ((p.get())->func(), 0); p.emplace(30); EXPECT_EQ(p->func(), 9); @@ -110,10 +110,10 @@ TEST(StaticPtr, CreateEmplace) { TEST(StaticPtr, CopyMove) { // Won't compile. Good. - // static_ptr p1(ceph::in_place_type_t{}, 3); + // static_ptr p1(std::in_place_type_t{}, 3); - static_ptr p1(ceph::in_place_type_t{}); - static_ptr p2(ceph::in_place_type_t{}, + static_ptr p1(std::in_place_type_t{}); + static_ptr p2(std::in_place_type_t{}, 3); // This also does not compile. Good. @@ -127,7 +127,7 @@ TEST(StaticPtr, CopyMove) { TEST(StaticPtr, ImplicitUpcast) { static_ptr p1; - static_ptr p2(ceph::in_place_type_t{}, 3); + static_ptr p2(std::in_place_type_t{}, 3); p1 = p2; EXPECT_EQ(p1->func(), 9); @@ -142,7 +142,7 @@ TEST(StaticPtr, ImplicitUpcast) { } TEST(StaticPtr, StaticCast) { - static_ptr p1(ceph::in_place_type_t{}, 3); + static_ptr p1(std::in_place_type_t{}, 3); static_ptr p2; p2 = ceph::static_pointer_cast(p1); @@ -157,25 +157,25 @@ TEST(StaticPtr, StaticCast) { TEST(StaticPtr, DynamicCast) { static constexpr auto sz = sizeof(great_grandchild); { - static_ptr p1(ceph::in_place_type_t{}, 3); + static_ptr p1(std::in_place_type_t{}, 3); auto p2 = ceph::dynamic_pointer_cast(p1); EXPECT_FALSE(p2); } { - static_ptr p1(ceph::in_place_type_t{}, 3); + static_ptr p1(std::in_place_type_t{}, 3); auto p2 = ceph::dynamic_pointer_cast(std::move(p1)); EXPECT_FALSE(p2); } { - static_ptr p1(ceph::in_place_type_t{}, 3); + static_ptr p1(std::in_place_type_t{}, 3); auto p2 = ceph::dynamic_pointer_cast(p1); EXPECT_TRUE(p2); EXPECT_EQ(p2->func(), 9); EXPECT_EQ(p2->call(10), 30); } { - static_ptr p1(ceph::in_place_type_t{}, 3); + static_ptr p1(std::in_place_type_t{}, 3); auto p2 = ceph::dynamic_pointer_cast(std::move(p1)); EXPECT_TRUE(p2); EXPECT_EQ(p2->func(), 9); @@ -254,7 +254,7 @@ struct exceptional { }; TEST(StaticPtr, Exceptional) { - static_ptr p1(ceph::in_place_type_t{}); + static_ptr p1(std::in_place_type_t{}); EXPECT_ANY_THROW(static_ptr p2(p1)); EXPECT_ANY_THROW(static_ptr p2(std::move(p1))); }