I am trying to understand C++ template meta-programming in deeper concept. What I fail to understand is what a template really means. Specifically, what the idiom is for a templated class with static members. Take the following example:
template <class T>
class Matrix {
private:
public:
static constexpr Matrix<T> Identity(int,int);
static constexpr Matrix<T> Zero(int,int);
static constexpr Matrix<T> Null = Matrix();
typdef value_type;
Matrix();
Matrix(int,int);
}
The static member functions of Matrix obviously construct typical matrices. My thoughts were that the way to think about the text (the idiom) Matrix<T>::Identity would be the identity matrix of a class with value_type = T.
TL;DR
To restate, I believe that the template above generates a set of classes with respective static members Matrix<T>::Identity of their 'type'. This is in comparison to the other intuitive semantics of some Matrix::Identity<T>() which would be a Identity of type T for all matrices. Which is correct?
Hope that made sense! Thanks so much.
Aucun commentaire:
Enregistrer un commentaire