]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: Remove backported typedefs
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 22 Dec 2017 21:41:58 +0000 (16:41 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 8 Jan 2018 20:30:05 +0000 (15:30 -0500)
Since they're no longer needed.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/common/backport_std.h
src/common/convenience.h
src/common/static_ptr.h
src/include/scope_guard.h
src/test/common/test_static_ptr.cc

index 880b103deb8cbf5c3e374cddfe7ff146f2d5f709..e6b0c700c8d43202e7be62000b4e4349a6c1d580 100644 (file)
 // 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;
@@ -185,15 +68,6 @@ template <typename F>
 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 {
@@ -259,10 +133,6 @@ make_ostream_joiner(std::basic_ostream<CharT, Traits>& 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
index 66baf562d2922dc3a4778c7c05ff46f3566f62c8..49a74a3b3ae187637a63631e3b6eb72cfb095b01 100644 (file)
@@ -192,7 +192,7 @@ template<typename T, typename F, typename U>
 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);
index fd8b0e07f07d365ef821d0d5f1ccfcbdbee36605..54542ab2ffdf4c2e51c8770f5b8b3365e09620e7 100644 (file)
@@ -86,12 +86,12 @@ class static_ptr {
   //
   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;
   }
@@ -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<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);
     }
@@ -149,7 +149,7 @@ public:
 
   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);
@@ -157,7 +157,7 @@ public:
   }
   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);
@@ -165,7 +165,7 @@ public:
   }
 
   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;
@@ -175,7 +175,7 @@ public:
     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;
@@ -186,7 +186,7 @@ public:
 
   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) {
@@ -198,7 +198,7 @@ public:
   }
   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) {
@@ -215,13 +215,13 @@ public:
   // 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. "
@@ -239,7 +239,7 @@ public:
   //
   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>;
@@ -251,11 +251,11 @@ public:
     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 {
@@ -402,7 +402,7 @@ static_ptr<U, Z> reinterpret_pointer_cast(static_ptr<T, S>&& p) {
 // 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)) {
@@ -413,7 +413,7 @@ static_ptr<U, Z> resize_pointer_cast(const static_ptr<T, S>& p) {
 }
 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)) {
@@ -438,6 +438,6 @@ bool operator ==(std::nullptr_t, static_ptr<Base, Size> s) {
 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)... };
 }
 }
index 2c11d89f82d5c8445df96b5abb6d0549d6b3f738..b3eb3fd54700cdb02aa518a32f218b8bbf084e1c 100644 (file)
@@ -30,7 +30,7 @@ struct scope_guard {
   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
   }
@@ -42,8 +42,8 @@ scope_guard<F> make_scope_guard(F &&f) {
 }
 
 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
index 4a464d79f548d5f84071e1b89958d975247ae71b..bfa5733d81798a2acb610c83c2536b9185c9ba1e 100644 (file)
@@ -59,7 +59,7 @@ TEST(StaticPtr, EmptyCreation) {
 
 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);
@@ -82,7 +82,7 @@ TEST(StaticPtr, CreationCall) {
 
 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);
@@ -91,7 +91,7 @@ TEST(StaticPtr, CreateReset) {
     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);
@@ -102,7 +102,7 @@ TEST(StaticPtr, CreateReset) {
 }
 
 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);
@@ -110,10 +110,10 @@ TEST(StaticPtr, CreateEmplace) {
 
 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.
@@ -127,7 +127,7 @@ TEST(StaticPtr, CopyMove) {
 
 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);
@@ -142,7 +142,7 @@ TEST(StaticPtr, ImplicitUpcast) {
 }
 
 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);
@@ -157,25 +157,25 @@ TEST(StaticPtr, StaticCast) {
 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);
@@ -254,7 +254,7 @@ struct exceptional {
 };
 
 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)));
 }