Re: [eigen] Taking advantage of C++11 features in Eigen

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 02/12/2014 12:44:25 PM, Christoph Hertzberg wrote:
On 11.02.2014 20:54, Nicola Gigante wrote:
I’m recently starting to follow the Eigen project and I was wondering which is the current status of C++11 features support inside the library. It seems the library is “compatible” with C++11, meaning that it compiles and works properly with the new standard, but does not take
advantage of new features when available.

Generally, we want to keep Eigen C++03 compatible as much as possible. There are C++11 things implemented which don't jeopardize that, like move semantics.
https://bitbucket.org/eigen/eigen/src/90f8b868e6e2/Eigen/src/Core/Matrix.h?at=default#cl-220

Things like initializer lists might encourage people to rely on that and causing trouble when back-porting to C++03. We might allow things like that if the user explicitly includes something like <Eigen/CXX11/Core> -- we already had a similar discussion about that for the tensor module:
http://listengine.tuxfamily.org/lists.tuxfamily.org/eigen/2013/11/msg00000.html
** Addendum after reading the link from Jitse's mail: It appears initializer lists have much less power than our current CommaInitializer

I think most other features you suggested are at the moment a bit risky having still a lot of compilers around without or with incomplete C++11 support. IMHO we could consider using features if they give (measurable) performance improvements, but for now I wouldn't do it "just" for cleaner code or minor compile time reductions. We'd have to guard it with #ifdefs anyhow to keep C++03 compatibility, essentially making the code less clean.

I hope I did not entirely block you from contributing to Eigen. In the long run we definitely want more C++11 features in Eigen, but for now we should not risk C++03 compatibility.

Gnu's standard library is full of code like

#if defined(__cplusplus) && __cplusplus >= 201103L


and AFAIR  the preprocessor symbol cplusplus is standardized.

Helmut


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/