ソースを参照

Move get_ptr helpers to detail folder.

Sam Jaffe 5 年 前
コミット
7fdd82183a

+ 1 - 0
include/pointers/const_propogating_ptr.hpp

@@ -9,6 +9,7 @@
 #include <memory>
 
 #include "detail/compare.hpp"
+#include "detail/get_ptr.hpp"
 #include "pointer_fwd.hpp"
 
 template <typename P>

+ 1 - 0
include/pointers/const_ptr.hpp

@@ -9,6 +9,7 @@
 #include <memory>
 
 #include "detail/compare.hpp"
+#include "detail/get_ptr.hpp"
 #include "pointer_fwd.hpp"
 
 template <typename P>

+ 25 - 0
include/pointers/detail/get_ptr.hpp

@@ -0,0 +1,25 @@
+#pragma once
+
+namespace detail {
+  template <typename P, typename = void> struct get_ptr {
+    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; }
+  };
+
+  template <typename P>
+  struct get_ptr<P, typename std::enable_if<!std::is_void<decltype(
+                        std::declval<P>().get())>::value>::type> {
+    decltype(std::declval<P>().get()) get(P const & ptr) const {
+      return ptr.get();
+    }
+  };
+}

+ 1 - 0
include/pointers/maybe_null.hpp

@@ -11,6 +11,7 @@
 #include <memory>
 
 #include "detail/compare.hpp"
+#include "detail/get_ptr.hpp"
 #include "pointer_fwd.hpp"
 
 class unchecked_pointer_exception : public std::logic_error {

+ 0 - 22
include/pointers/pointer_fwd.hpp

@@ -30,26 +30,4 @@ namespace detail {
   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>;
-
-  template <typename P, typename = void> struct get_ptr {
-    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; }
-  };
-
-  template <typename P>
-  struct get_ptr<P, typename std::enable_if<!std::is_void<decltype(
-                        std::declval<P>().get())>::value>::type> {
-    decltype(std::declval<P>().get()) get(P const & ptr) const {
-      return ptr.get();
-    }
-  };
 }