Quellcode durchsuchen

Stop compressing noexcept declarations...

Sam Jaffe vor 5 Jahren
Ursprung
Commit
90a06dba49

+ 10 - 8
include/pointers/const_propogating_ptr.hpp

@@ -24,9 +24,11 @@ public:
   using const_reference = element_type const &;
 
   const_propogating_ptr() noexcept : _ptr() {}
-  const_propogating_ptr(P const & p) noexcept(detail::is_nt_cc<P>::value)
+  const_propogating_ptr(P const & p) noexcept(
+      std::is_nothrow_copy_constructible<P>::value)
       : _ptr(p) {}
-  const_propogating_ptr(P && p) noexcept(detail::is_nt_mc<P>::value)
+  const_propogating_ptr(P && p) noexcept(
+      std::is_nothrow_move_constructible<P>::value)
       : _ptr(std::move(p)) {}
   template <typename Y, typename = typename std::enable_if<
                             std::is_constructible<P, Y>::value>::type>
@@ -36,25 +38,25 @@ public:
   const_propogating_ptr(Y && p) : _ptr(std::forward<Y>(p)) {}
 
   const_propogating_ptr(const_propogating_ptr &) noexcept(
-      detail::is_nt_cc<P>::value) = default;
+      std::is_nothrow_copy_constructible<P>::value) = default;
   const_propogating_ptr(const_propogating_ptr &&) noexcept(
-      detail::is_nt_mc<P>::value) = default;
+      std::is_nothrow_move_constructible<P>::value) = default;
   const_propogating_ptr(const_propogating_ptr const &) = delete;
   const_propogating_ptr & operator=(const_propogating_ptr &) noexcept(
-      detail::is_nt_ca<P>::value) = default;
+      std::is_nothrow_copy_assignable<P>::value) = default;
   const_propogating_ptr & operator=(const_propogating_ptr &&) noexcept(
-      detail::is_nt_ma<P>::value) = default;
+      std::is_nothrow_move_assignable<P>::value) = default;
   const_propogating_ptr & operator=(const_propogating_ptr const &) = delete;
 
   template <typename Y>
       explicit operator const_propogating_ptr<Y>() &
-      noexcept(detail::is_nt_c<P, Y>::value) {
+      noexcept(std::is_nothrow_constructible<P, Y>::value) {
     return _ptr;
   }
 
   template <typename Y>
   explicit operator const_ptr<Y>() const
-      noexcept(detail::is_nt_c<P, Y>::value) {
+      noexcept(std::is_nothrow_constructible<P, Y>::value) {
     return _ptr;
   }
 

+ 5 - 3
include/pointers/const_ptr.hpp

@@ -21,8 +21,10 @@ public:
   using reference = element_type const &;
 
   const_ptr() noexcept : _ptr(nullptr) {}
-  const_ptr(P const & p) noexcept(detail::is_nt_cc<P>::value) : _ptr(p) {}
-  const_ptr(P && p) noexcept(detail::is_nt_mc<P>::value) : _ptr(std::move(p)) {}
+  const_ptr(P const & p) noexcept(std::is_nothrow_copy_constructible<P>::value)
+      : _ptr(p) {}
+  const_ptr(P && p) noexcept(std::is_nothrow_move_constructible<P>::value)
+      : _ptr(std::move(p)) {}
   template <typename Y, typename = typename std::enable_if<
                             std::is_constructible<P, Y>::value>::type>
   const_ptr(Y const & p) : _ptr(p) {}
@@ -32,7 +34,7 @@ public:
 
   template <typename Y>
   explicit operator const_ptr<Y>() const
-      noexcept(detail::is_nt_c<P, Y>::value) {
+      noexcept(std::is_nothrow_constructible<P, Y>::value) {
     return _ptr;
   }
 

+ 13 - 9
include/pointers/maybe_null.hpp

@@ -35,8 +35,9 @@ public:
   using reference = element_type &;
 
   maybe_null() noexcept : _ptr(nullptr) {}
-  maybe_null(P const & p) noexcept(detail::is_nt_cc<P>::value) : _ptr(p) {}
-  maybe_null(P && p) noexcept(detail::is_nt_mc<P>::value)
+  maybe_null(P const & p) noexcept(std::is_nothrow_copy_constructible<P>::value)
+      : _ptr(p) {}
+  maybe_null(P && p) noexcept(std::is_nothrow_move_constructible<P>::value)
       : _ptr(std::move(p)) {}
   template <typename Y, typename = typename std::enable_if<
                             std::is_constructible<P, Y>::value>::type>
@@ -44,18 +45,21 @@ public:
   template <typename Y, typename = typename std::enable_if<
                             std::is_constructible<P, Y>::value>::type>
   maybe_null(Y && p) : _ptr(std::forward<Y>(p)) {}
-  maybe_null(maybe_null const &) noexcept(detail::is_nt_cc<P>::value) = default;
-  maybe_null(maybe_null &&) noexcept(detail::is_nt_mc<P>::value) = default;
+  maybe_null(maybe_null const &) noexcept(
+      std::is_nothrow_copy_constructible<P>::value) = default;
+  maybe_null(maybe_null &&) noexcept(
+      std::is_nothrow_move_constructible<P>::value) = default;
   template <typename Y>
-  maybe_null(maybe_null<Y> const & other) noexcept(detail::is_nt_c<P, Y>::value)
+  maybe_null(maybe_null<Y> const & other) noexcept(
+      std::is_nothrow_constructible<P, Y>::value)
       : _ptr(other._ptr) {
     set_tested(other.tested_);
   }
 
-  maybe_null &
-  operator=(maybe_null const &) noexcept(detail::is_nt_ca<P>::value) = default;
-  maybe_null &
-  operator=(maybe_null &&) noexcept(detail::is_nt_ma<P>::value) = default;
+  maybe_null & operator=(maybe_null const &) noexcept(
+      std::is_nothrow_copy_assignable<P>::value) = default;
+  maybe_null & operator=(maybe_null &&) noexcept(
+      std::is_nothrow_move_assignable<P>::value) = default;
 
   operator bool() const noexcept {
     set_tested(true);

+ 7 - 5
include/pointers/not_null.hpp

@@ -38,21 +38,23 @@ public:
   not_null(Y && p) : _ptr(std::forward<Y>(p)) {
     validate();
   }
-  not_null(not_null const &) noexcept(detail::is_nt_cc<P>::value) = default;
+  not_null(not_null const &) noexcept(
+      std::is_nothrow_copy_constructible<P>::value) = default;
   not_null(not_null &&) = delete;
 
   template <typename Y>
   explicit operator maybe_null<Y>() const
-      noexcept(detail::is_nt_c<Y, P>::value) {
+      noexcept(std::is_nothrow_constructible<Y, P>::value) {
     return _ptr;
   }
   template <typename Y>
-  explicit operator not_null<Y>() const noexcept(detail::is_nt_c<Y, P>::value) {
+  explicit operator not_null<Y>() const
+      noexcept(std::is_nothrow_constructible<Y, P>::value) {
     return _ptr;
   }
 
-  not_null &
-  operator=(not_null const &) noexcept(detail::is_nt_ca<P>::value) = default;
+  not_null & operator=(not_null const &) noexcept(
+      std::is_nothrow_copy_assignable<P>::value) = default;
   not_null & operator=(not_null &&) = delete;
 
   operator bool() const noexcept { return true; }

+ 0 - 11
include/pointers/pointer_fwd.hpp

@@ -20,14 +20,3 @@ class unchecked_pointer_exception;
 class null_pointer_exception : public std::invalid_argument {
   using std::invalid_argument::invalid_argument;
 };
-
-namespace detail {
-  template <typename P> using is_nt_cc = std::is_nothrow_copy_constructible<P>;
-  template <typename P> using is_nt_ca = std::is_nothrow_copy_assignable<P>;
-  template <typename P> using is_nt_mc = std::is_nothrow_move_constructible<P>;
-  template <typename P> using is_nt_ma = std::is_nothrow_move_assignable<P>;
-  template <typename P, typename Y>
-  using is_nt_c = std::is_nothrow_constructible<P, Y>;
-  template <typename P, typename Y>
-  using is_nt_a = std::is_nothrow_assignable<P, Y>;
-}

+ 1 - 1
include/pointers/value_ptr.hpp

@@ -47,7 +47,7 @@ public:
 
   value_ptr() noexcept : _ptr(nullptr) {}
   value_ptr(T * const & p) = delete;
-  value_ptr(T *&& p) noexcept(detail::is_nt_mc<T>::value)
+  value_ptr(T *&& p) noexcept(std::is_nothrow_move_constructible<T>::value)
       : _ptr(std::move(p)) {}
   value_ptr(value_ptr const & other)
       : _ptr(detail::value_ptr_copy<T>::Copy(other._ptr)) {}