Pārlūkot izejas kodu

Split vector into helper files.

Sam Jaffe 5 gadi atpakaļ
vecāks
revīzija
dc8476ffc0

+ 15 - 0
include/math/vector/forward.h

@@ -0,0 +1,15 @@
+#pragma once
+
+#include <cstdlib>
+
+namespace math { namespace vector {
+  template <typename T, std::size_t N> class vector;
+
+  struct {
+  } fill;
+  using fill_t = decltype(fill);
+}}
+
+namespace math { namespace matrix {
+  template <typename T, std::size_t R, std::size_t C> class matrix;
+}}

+ 18 - 0
include/math/vector/traits.hpp

@@ -0,0 +1,18 @@
+#pragma once
+
+namespace math { namespace vector {
+
+  template <typename T> struct is_vector {
+    static const constexpr bool value = false;
+  };
+
+  template <typename T, std::size_t N> struct is_vector<vector<T, N>> {
+    static const constexpr bool value = true;
+  };
+
+  template <typename T, std::size_t R, std::size_t C>
+  struct is_vector<matrix::matrix<T, R, C>> {
+    static const constexpr bool value = true;
+  };
+
+}}

+ 3 - 20
include/math/vector/vector.hpp

@@ -18,11 +18,9 @@
 
 #include "expect/expect.hpp"
 
-namespace math { namespace matrix {
-  template <typename, size_t, size_t> class matrix;
-}}
+#include "forward.h"
+#include "traits.hpp"
 
-namespace math { namespace vector {
 #define VECTOR_ENABLE_IF_LT_N(index, expr)                                     \
   template <bool _ = true>                                                     \
   typename std::enable_if<std::size_t(index) < N && _, expr>::type
@@ -47,22 +45,7 @@ namespace math { namespace vector {
   for (std::size_t var = 0; var < end; ++var)
 #define VECTOR_FOR_EACH(var) VECTOR_FOR_EACH_RANGE(var, N)
 
-  struct {
-  } fill;
-  using fill_t = decltype(fill);
-
-  template <typename T> struct is_vector {
-    static const constexpr bool value = false;
-  };
-
-  template <typename T, std::size_t N> class vector;
-  template <typename T, std::size_t N> struct is_vector<vector<T, N>> {
-    static const constexpr bool value = true;
-  };
-  template <typename T, std::size_t R, std::size_t C>
-  struct is_vector<matrix::matrix<T, R, C>> {
-    static const constexpr bool value = true;
-  };
+namespace math { namespace vector {
 
   template <typename T, std::size_t N> class vector {
   public:

+ 1 - 1
vector.xcodeproj/xcuserdata/samjaffe.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -7,7 +7,7 @@
 		<key>vector-test.xcscheme_^#shared#^_</key>
 		<dict>
 			<key>orderHint</key>
-			<integer>51</integer>
+			<integer>48</integer>
 		</dict>
 	</dict>
 	<key>SuppressBuildableAutocreation</key>