This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 864 - C++11 alias templates for commonly used types
Summary: C++11 alias templates for commonly used types
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords: JuniorJob
Depends on:
Blocks: 3.4
  Show dependency treegraph
 
Reported: 2014-08-26 06:36 UTC by Jim Garrison
Modified: 2019-12-04 13:38 UTC (History)
3 users (show)



Attachments
eigen3-typedefs.hpp (1.47 KB, text/x-c++hdr)
2014-08-26 06:36 UTC, Jim Garrison
no flags Details

Description Jim Garrison 2014-08-26 06:36:33 UTC
Created attachment 489 [details]
eigen3-typedefs.hpp

[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:

    Eigen::MatrixX<T> mat;

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.
Comment 1 Gael Guennebaud 2014-08-26 10:31:25 UTC
IIRC, the idea was to add a module <Eigen/CXX11/Core> which would include Eigen/Core and its own source files in Eigen/CXX11/src/Core/, e.g.;

Eigen/CXX11/src/Core/Typedefs.h

We should also add a documentation page summarising C++11 features.
Comment 2 Gael Guennebaud 2019-02-20 14:25:39 UTC
At last:

https://bitbucket.org/eigen/eigen/commits/39fed2ad6650/
Summary:     alias template for matrix and array classes (PR 180)

https://bitbucket.org/eigen/eigen/commits/fed0f93f7118/
Summary:     Add fully generic Vector<Type,Size> and RowVector<Type,Size> type aliases.
Comment 3 Nobody 2019-12-04 13:38:28 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/864.

Note You need to log in before you can comment on or make changes to this bug.