@@ -38,7 +38,7 @@ template<typename T, glm::precision P>
3838struct type_caster<glm::tvec2<T, P>>
3939{
4040 using vector_type = glm::tvec2<T, P>;
41- typedef typename T Scalar ;
41+ using Scalar = T ;
4242 static constexpr std::size_t num_elements = 2 ;
4343
4444 bool load (handle src, bool )
@@ -75,18 +75,14 @@ struct type_caster<glm::tvec2<T, P>>
7575
7676 // Specifies the doc-string for the type in Python:
7777 PYBIND11_TYPE_CASTER (vector_type, _ (" numpy.ndarray[" ) + npy_format_descriptor<Scalar>::name () +
78- _ (" [" ) + elements () + _ (" ]]" ));
79-
80- protected:
81- template <typename T = vector_type>
82- static PYBIND11_DESCR elements () { return _ (std::to_string (num_elements).c_str ()); }
78+ _ (" [" ) + _<num_elements>() + _ (" ]]" ));
8379};
8480
8581template <typename T, glm::precision P>
8682struct type_caster <glm::tvec3<T, P>>
8783{
8884 using vector_type = glm::tvec3<T, P>;
89- typedef typename T Scalar ;
85+ using Scalar = T ;
9086 static constexpr std::size_t num_elements = 3 ;
9187
9288 bool load (handle src, bool )
@@ -123,18 +119,14 @@ struct type_caster<glm::tvec3<T, P>>
123119
124120 // Specifies the doc-string for the type in Python:
125121 PYBIND11_TYPE_CASTER (vector_type, _(" numpy.ndarray[" ) + npy_format_descriptor<Scalar>::name() +
126- _ (" [" ) + elements() + _(" ]]" ));
127-
128- protected:
129- template <typename T = vector_type>
130- static PYBIND11_DESCR elements () { return _ (std::to_string (num_elements).c_str ()); }
122+ _ (" [" ) + _<num_elements>() + _(" ]]" ));
131123};
132124
133125template <typename T, glm::precision P>
134126struct type_caster <glm::tvec4<T, P>>
135127{
136128 using vector_type = glm::tvec4<T, P>;
137- typedef typename T Scalar ;
129+ using Scalar = T ;
138130 static constexpr std::size_t num_elements = 4 ;
139131
140132 bool load (handle src, bool )
@@ -171,18 +163,14 @@ struct type_caster<glm::tvec4<T, P>>
171163
172164 // Specifies the doc-string for the type in Python:
173165 PYBIND11_TYPE_CASTER (vector_type, _(" numpy.ndarray[" ) + npy_format_descriptor<Scalar>::name() +
174- _ (" [" ) + elements() + _(" ]]" ));
175-
176- protected:
177- template <typename T = vector_type>
178- static PYBIND11_DESCR elements () { return _ (std::to_string (num_elements).c_str ()); }
166+ _ (" [" ) + _<num_elements>() + _(" ]]" ));
179167};
180168
181169template <typename T, glm::precision P>
182170struct type_caster <glm::tmat3x3<T, P>>
183171{
184172 using matrix_type = glm::tmat3x3<T, P>;
185- typedef typename T Scalar ;
173+ using Scalar = T ;
186174 static constexpr std::size_t num_rows = 3 ;
187175 static constexpr std::size_t num_cols = 3 ;
188176
@@ -223,20 +211,14 @@ struct type_caster<glm::tmat3x3<T, P>>
223211
224212 // Specifies the doc-string for the type in Python:
225213 PYBIND11_TYPE_CASTER (matrix_type, _(" numpy.ndarray[" ) + npy_format_descriptor<Scalar>::name() +
226- _ (" [" ) + rows() + _(" , " ) + cols() + _(" ]]" ));
227-
228- protected:
229- template <typename T = matrix_type>
230- static PYBIND11_DESCR rows () { return _ (std::to_string (num_rows).c_str ()); }
231- template <typename T = matrix_type>
232- static PYBIND11_DESCR cols () { return _ (std::to_string (num_cols).c_str ()); }
214+ _ (" [" ) + _<num_rows>() + _(" , " ) + _<num_cols>() + _(" ]]" ));
233215};
234216
235217template <typename T, glm::precision P>
236218struct type_caster <glm::tmat4x3<T, P>>
237219{
238220 using matrix_type = glm::tmat4x3<T, P>;
239- typedef typename T Scalar ;
221+ using Scalar = T ;
240222 static constexpr std::size_t num_rows = 3 ;
241223 static constexpr std::size_t num_cols = 4 ;
242224
@@ -277,20 +259,14 @@ struct type_caster<glm::tmat4x3<T, P>>
277259
278260 // Specifies the doc-string for the type in Python:
279261 PYBIND11_TYPE_CASTER (matrix_type, _(" numpy.ndarray[" ) + npy_format_descriptor<Scalar>::name() +
280- _ (" [" ) + rows() + _(" , " ) + cols() + _(" ]]" ));
281-
282- protected:
283- template <typename T = matrix_type>
284- static PYBIND11_DESCR rows () { return _ (std::to_string (num_rows).c_str ()); }
285- template <typename T = matrix_type>
286- static PYBIND11_DESCR cols () { return _ (std::to_string (num_cols).c_str ()); }
262+ _ (" [" ) + _<num_rows>() + _(" , " ) + _<num_cols>() + _(" ]]" ));
287263};
288264
289265template <typename T, glm::precision P>
290266struct type_caster <glm::tmat4x4<T, P>>
291267{
292268 using matrix_type = glm::tmat4x4<T, P>;
293- typedef typename T Scalar ;
269+ using Scalar = T ;
294270 static constexpr std::size_t num_rows = 4 ;
295271 static constexpr std::size_t num_cols = 4 ;
296272
@@ -331,13 +307,7 @@ struct type_caster<glm::tmat4x4<T, P>>
331307
332308 // Specifies the doc-string for the type in Python:
333309 PYBIND11_TYPE_CASTER (matrix_type, _(" numpy.ndarray[" ) + npy_format_descriptor<Scalar>::name() +
334- _ (" [" ) + rows() + _(" , " ) + cols() + _(" ]]" ));
335-
336- protected:
337- template <typename T = matrix_type>
338- static PYBIND11_DESCR rows () { return _ (std::to_string (num_rows).c_str ()); }
339- template <typename T = matrix_type>
340- static PYBIND11_DESCR cols () { return _ (std::to_string (num_cols).c_str ()); }
310+ _ (" [" ) + _<num_rows>() + _(" , " ) + _<num_cols>() + _(" ]]" ));
341311};
342312
343313NAMESPACE_END (detail)
0 commit comments