C++11 alias templates for commonly used types
Submitted by Jim Garrison
Assigned to Nobody
Created attachment 489
[This was posted previously at http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2014/02/msg00069.html but I never made a bug for it in bugzilla]
Another C++11 feature I'd like to see available to users is alias
templates for commonly used types.
Currently, users can create e.g. an arbitrary sized matrix of doubles
using the Eigen::MatrixXd typedef, defined in Eigen/src/Core/Matrix.h.
However, if one wants to do this with a templated type, it is necessary
to write out in full each time:
Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> mat;
The attached header defines alias templates similar to MatrixXd, etc.,
which allow for the same functionality with less verbosity. With this,
the above type definition can be written as:
I've been using this now for several months and it makes my code much
clearer. Please feel free to adapt it and include it in Eigen.
Gael suggested this should go in a separate C++11 module, but it's unclear to me specifically how it should fit in the directory tree, so I attach it here as just a single file.
Attachment 489, "eigen3-typedefs.hpp":