소스 검색

Moving various trait structs into streams/traits.hpp

Samuel Jaffe 8 년 전
부모
커밋
0e206aed8d
5개의 변경된 파일54개의 추가작업 그리고 37개의 파일을 삭제
  1. 2 0
      stream.xcodeproj/project.pbxproj
  2. 0 14
      streams/filter.hpp
  3. 2 0
      streams/forward.hpp
  4. 0 23
      streams/streams.hpp
  5. 50 0
      streams/traits.hpp

+ 2 - 0
stream.xcodeproj/project.pbxproj

@@ -33,6 +33,7 @@
 		CD9337271E3CD78B00699FF5 /* stream_tc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = stream_tc.cpp; sourceTree = "<group>"; };
 		CD9337281E3CD78B00699FF5 /* stream.t.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stream.t.h; sourceTree = "<group>"; };
 		CD93372D1E3CD79E00699FF5 /* stream_tc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = stream_tc; sourceTree = BUILT_PRODUCTS_DIR; };
+		CDD8C6331EFEA1EA008229C4 /* traits.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = traits.hpp; sourceTree = "<group>"; };
 		CDF9374C1E3D81D4003E5D5C /* fluent.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = fluent.hpp; sourceTree = "<group>"; };
 		CDF9374E1E3D9AD7003E5D5C /* stream_fluent.t.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stream_fluent.t.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -67,6 +68,7 @@
 				0EB833511BBF45FD00DDC844 /* source.hpp */,
 				0EB833521BBF45FD00DDC844 /* streams.hpp */,
 				CDF9374C1E3D81D4003E5D5C /* fluent.hpp */,
+				CDD8C6331EFEA1EA008229C4 /* traits.hpp */,
 			);
 			path = streams;
 			sourceTree = "<group>";

+ 0 - 14
streams/filter.hpp

@@ -1,20 +1,6 @@
 #pragma once
 
 namespace stream { namespace detail {
-  template <typename T>
-  struct ref_or_val {
-    ref_or_val operator=(T && val) { value = std::move(val); return *this; }
-    operator T const &() const { return value; }
-    T value;
-  };
-
-  template <typename T>
-  struct ref_or_val<T&> {
-    ref_or_val operator=(T & val) { value = &val; return *this; }
-    operator T &() const { return *value; }
-    T * value;
-  };
-
   namespace filter {
     template <typename T>
     class iterator : public iterator_impl<T> {

+ 2 - 0
streams/forward.hpp

@@ -1,5 +1,7 @@
 #pragma once
 
+#include "traits.hpp"
+
 namespace stream {
   namespace detail {
     template <typename> class stream_base;

+ 0 - 23
streams/streams.hpp

@@ -15,29 +15,6 @@ super& operator++() override { ++impl; return *this; } \
 DELEGATE_ITERATOR_IMPL_BASE(impl)
 
 namespace stream {
-  namespace detail {
-    template <typename F> struct map_member_object;
-    template <typename T, typename R>
-    struct map_member_object<R T::*> {
-      using type = R const &;
-      type operator()(T const & val) const { return val.*mem; }
-      R T::*mem;
-    };
-    template <typename F> struct map_member_function;
-    template <typename T, typename R>
-    struct map_member_function<R (T::*)() const> {
-      using type = R;
-      type operator()(T const & val) const { return val.*mem(); }
-      R (T::* mem)() const;
-    };
-    
-    template <typename T, typename = void>
-    struct is_dereferencable : public std::false_type {};
-    
-    template <typename T>
-    struct is_dereferencable<T, typename std::enable_if<!std::is_void<decltype(*std::declval<T>())>::value>::type> : public std::true_type {};
-  }
-  
   template <typename T>
   class iterator {
   public:

+ 50 - 0
streams/traits.hpp

@@ -0,0 +1,50 @@
+//
+//  traits.hpp
+//  stream
+//
+//  Created by Sam Jaffe on 6/24/17.
+//
+
+#pragma once
+
+namespace stream { namespace detail {
+  template <typename T>
+  struct ref_or_val {
+    ref_or_val operator=(T && val) { value = std::move(val); return *this; }
+    operator T const &() const { return value; }
+    T value;
+  };
+  
+  template <typename T>
+  struct ref_or_val<T&> {
+    ref_or_val operator=(T & val) { value = &val; return *this; }
+    operator T &() const { return *value; }
+    T * value;
+  };
+} }
+
+namespace stream { namespace detail {
+  template <typename F> struct map_member_object;
+  template <typename T, typename R>
+  struct map_member_object<R T::*> {
+    using type = R const &;
+    type operator()(T const & val) const { return val.*mem; }
+    R T::*mem;
+  };
+  
+  template <typename F> struct map_member_function;
+  template <typename T, typename R>
+  struct map_member_function<R (T::*)() const> {
+    using type = R;
+    type operator()(T const & val) const { return val.*mem(); }
+    R (T::* mem)() const;
+  };
+}}
+
+namespace stream { namespace detail {
+  template <typename T, typename = void>
+  struct is_dereferencable : public std::false_type {};
+  
+  template <typename T>
+  struct is_dereferencable<T, typename std::enable_if<!std::is_void<decltype(*std::declval<T>())>::value>::type> : public std::true_type {};
+}}