Selaa lähdekoodia

Fixing some issues with rvalue constructors.

Samuel Jaffe 8 vuotta sitten
vanhempi
commit
d96c2d8d31
5 muutettua tiedostoa jossa 10 lisäystä ja 5 poistoa
  1. 2 2
      const_propogating_ptr.hpp
  2. 1 1
      const_ptr.hpp
  3. 1 1
      maybe_null.hpp
  4. 1 1
      not_null.hpp
  5. 5 0
      pointer_fwd.hpp

+ 2 - 2
const_propogating_ptr.hpp

@@ -20,13 +20,13 @@ public:
   using const_pointer = element_type const *;
   using const_reference = element_type const &;
 
-  const_propogating_ptr() noexcept : _ptr(nullptr) {}
+  const_propogating_ptr() noexcept : _ptr() {}
   const_propogating_ptr(P const & p) noexcept(detail::is_nt_cc<P>::value) : _ptr(p) {}
   const_propogating_ptr(P && p) noexcept(detail::is_nt_mc<P>::value) : _ptr(std::move(p)) {}
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
   const_propogating_ptr(Y const & p) : _ptr(p) { }
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
-  const_propogating_ptr(Y && p) : _ptr(std::move(p)) { }
+  const_propogating_ptr(Y && p) : _ptr(std::forward<Y>(p)) { }
 
   const_propogating_ptr(const_propogating_ptr &) noexcept(detail::is_nt_cc<P>::value) = default;
   const_propogating_ptr(const_propogating_ptr &&) noexcept(detail::is_nt_mc<P>::value) = default;

+ 1 - 1
const_ptr.hpp

@@ -24,7 +24,7 @@ public:
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
   const_ptr(Y const & p) : _ptr(p) { }
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
-  const_ptr(Y && p) : _ptr(std::move(p)) { }
+  const_ptr(Y && p) : _ptr(std::forward<Y>(p)) { }
 
   template <typename Y>
   explicit operator const_ptr<Y>() const noexcept(detail::is_nt_c<P, Y>::value) {

+ 1 - 1
maybe_null.hpp

@@ -38,7 +38,7 @@ public:
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
   maybe_null(Y const & p) : _ptr(p) { }
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
-  maybe_null(Y && p) : _ptr(std::move(p)) { }
+  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;
   template <typename Y>

+ 1 - 1
not_null.hpp

@@ -30,7 +30,7 @@ public:
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
   not_null(Y const & p) : _ptr(p) { validate(); }
   template <typename Y, typename = typename std::enable_if<std::is_constructible<P, Y>::value>::type>
-  not_null(Y && p) : _ptr(std::move(p)) { validate(); }
+  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 &&) = delete;
   

+ 5 - 0
pointer_fwd.hpp

@@ -40,6 +40,11 @@ namespace detail {
     decltype(std::declval<P>().get()) get( P const & ptr ) const { return std::addressof(*ptr); }
   };
   
+  template <typename T>
+  struct get_ptr<std::weak_ptr<T>> {
+    void get( std::weak_ptr<T> const & ptr ) throw();
+  };
+
   template <typename T>
   struct get_ptr<T*> {
     T* get( T* ptr ) const { return ptr; }