Browse Source

length becomes a static function #565

Christophe Riccio 9 years ago
parent
commit
9298939816
4 changed files with 18 additions and 9 deletions
  1. 1 1
      glm/detail/type_vec4.hpp
  2. 0 6
      glm/detail/type_vec4.inl
  3. 1 1
      glm/gtc/random.inl
  4. 16 1
      test/core/core_func_noise.cpp

+ 1 - 1
glm/detail/type_vec4.hpp

@@ -79,7 +79,7 @@ namespace glm
 
 
 		/// Return the count of components of the vector
 		/// Return the count of components of the vector
 		typedef length_t length_type;
 		typedef length_t length_type;
-		GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
+		GLM_FUNC_DECL static length_type length(){return 4;}
 
 
 		GLM_FUNC_DECL T & operator[](length_type i);
 		GLM_FUNC_DECL T & operator[](length_type i);
 		GLM_FUNC_DECL T const & operator[](length_type i) const;
 		GLM_FUNC_DECL T const & operator[](length_type i) const;

+ 0 - 6
glm/detail/type_vec4.inl

@@ -324,12 +324,6 @@ namespace detail
 
 
 	// -- Component accesses --
 	// -- Component accesses --
 
 
-	template <typename T, precision P>
-	GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec4<T, P>::length_type tvec4<T, P>::length() const
-	{
-		return 4;
-	}
-
 	template <typename T, precision P>
 	template <typename T, precision P>
 	GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](typename tvec4<T, P>::length_type i)
 	GLM_FUNC_QUALIFIER T & tvec4<T, P>::operator[](typename tvec4<T, P>::length_type i)
 	{
 	{

+ 1 - 1
glm/gtc/random.inl

@@ -154,7 +154,7 @@ namespace detail
 			return (compute_rand<uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
 			return (compute_rand<uint32, P, vecType>::call() % (Max + static_cast<uint32>(1) - Min)) + Min;
 		}
 		}
 	};
 	};
-
+ 
 	template <precision P, template <class, precision> class vecType>
 	template <precision P, template <class, precision> class vecType>
 	struct compute_linearRand<int64, P, vecType>
 	struct compute_linearRand<int64, P, vecType>
 	{
 	{

+ 16 - 1
test/core/core_func_noise.cpp

@@ -1,7 +1,22 @@
+struct vec4
+{
+	static int length();
+};
+
+int vec4::length()
+{
+	return 4;
+}
+
 int main()
 int main()
 {
 {
 	int Failed = 0;
 	int Failed = 0;
-	
+
+	vec4 V;
+
+	int LengthA = V.length();
+	int LengthB = vec4::length();
+
 	return Failed;
 	return Failed;
 }
 }