2
0
Эх сурвалжийг харах

length() member functions are constexpr #657

Christophe Riccio 8 жил өмнө
parent
commit
1b78e2b681

+ 8 - 8
glm/detail/type_mat2x2.hpp

@@ -24,6 +24,14 @@ namespace glm
 		col_type value[2];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 2; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -66,14 +74,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<3, 4, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 2;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<2, 2, T, P> & operator=(mat<2, 2, T, P> const & v) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat2x3.hpp

@@ -25,6 +25,14 @@ namespace glm
 		col_type value[2];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 2; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -67,14 +75,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 2, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 2;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<2, 3, T, P> & operator=(mat<2, 3, T, P> const & m) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat2x4.hpp

@@ -25,6 +25,14 @@ namespace glm
 		col_type value[2];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 2; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -69,14 +77,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 2, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 2;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<2, 4, T, P> & operator=(mat<2, 4, T, P> const & m) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat3x2.hpp

@@ -25,6 +25,14 @@ namespace glm
 		col_type value[3];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 3; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -74,14 +82,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 2, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 3;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<3, 2, T, P> & operator=(mat<3, 2, T, P> const & m) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat3x3.hpp

@@ -24,6 +24,14 @@ namespace glm
 		col_type value[3];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 3; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -73,14 +81,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<3, 4, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 3;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<3, 3, T, P> & operator=(mat<3, 3, T, P> const & m) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat3x4.hpp

@@ -25,6 +25,14 @@ namespace glm
 		col_type value[3];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 3; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -74,14 +82,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 2, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 3;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<3, 4, T, P> & operator=(mat<3, 4, T, P> const & m) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat4x2.hpp

@@ -25,6 +25,14 @@ namespace glm
 		col_type value[4];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 4; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -79,14 +87,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 3, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<3, 4, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 4;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<4, 2, T, P> & operator=(mat<4, 2, T, P> const & m) GLM_DEFAULT;

+ 8 - 8
glm/detail/type_mat4x3.hpp

@@ -25,6 +25,14 @@ namespace glm
 		col_type value[4];
 
 	public:
+		// -- Accesses --
+
+		typedef length_t length_type;
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length() { return 4; }
+
+		GLM_FUNC_DECL col_type & operator[](length_type i);
+		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
+
 		// -- Constructors --
 
 		GLM_FUNC_DECL mat() GLM_DEFAULT_CTOR;
@@ -79,14 +87,6 @@ namespace glm
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<4, 2, T, P> const & x);
 		GLM_FUNC_DECL GLM_EXPLICIT mat(mat<3, 4, T, P> const & x);
 
-		// -- Accesses --
-
-		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 4;}
-
-		GLM_FUNC_DECL col_type & operator[](length_type i);
-		GLM_FUNC_DECL col_type const & operator[](length_type i) const;
-
 		// -- Unary arithmetic operators --
 
 		GLM_FUNC_DECL mat<4, 3, T, P> & operator=(mat<4, 3, T, P> const & m) GLM_DEFAULT;

+ 1 - 1
glm/detail/type_mat4x4.hpp

@@ -27,7 +27,7 @@ namespace glm
 		// -- Accesses --
 
 		typedef length_t length_type;
-		GLM_FUNC_DECL static length_type length(){return 4;}
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 4;}
 
 		GLM_FUNC_DECL col_type & operator[](length_type i);
 		GLM_FUNC_DECL col_type const & operator[](length_type i) const;

+ 1 - 1
glm/detail/type_vec1.hpp

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

+ 1 - 1
glm/detail/type_vec2.hpp

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

+ 1 - 1
glm/detail/type_vec3.hpp

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

+ 1 - 1
glm/detail/type_vec4.hpp

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

+ 1 - 1
glm/gtc/quaternion.hpp

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

+ 1 - 1
glm/gtx/dual_quaternion.hpp

@@ -49,7 +49,7 @@ namespace glm
 
 		typedef length_t length_type;
 		/// Return the count of components of a dual quaternion
-		GLM_FUNC_DECL static length_type length(){return 2;}
+		GLM_FUNC_DECL static GLM_CONSTEXPR length_type length(){return 2;}
 
 		GLM_FUNC_DECL part_type & operator[](length_type i);
 		GLM_FUNC_DECL part_type const & operator[](length_type i) const;

+ 2 - 1
readme.md

@@ -74,7 +74,8 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
 - Removed GCC shadow warnings #595
 - Added error for including of different versions of GLM #619
 - Added GLM_FORCE_IGNORE_VERSION to ignore error caused by including different version of GLM #619
-- Reduced warnings when using very strict compilation flags #646 
+- Reduced warnings when using very strict compilation flags #646
+- length() member functions are constexpr #657
 
 #### Fixes:
 - Removed doxygen references to GTC_half_float which was removed in 0.9.4