New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 455 - aligned_allocator error with gnu++0x flag
Summary: aligned_allocator error with gnu++0x flag
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2012-04-26 21:59 UTC by daviddoria
Modified: 2012-05-03 17:45 UTC (History)
3 users (show)


Description daviddoria 2012-04-26 21:59:55 UTC
I have posted the full demonstration here:

but essentially this code:

typedef std::vector<Eigen::Vector2d,Eigen::aligned_allocator<Eigen::Vector2d> > Point2DVector;

Point2DVector points(5);

compiles fine without the gnu++0x flag, but I get this error with that flag:

error: no matching function for call to ‘Eigen::aligned_allocator<Eigen::Matrix<double, 2, 1> >::construct(Eigen::Matrix<double, 2, 1>*)’
Comment 1 Gael Guennebaud 2012-04-30 14:16:29 UTC
Fixing this issue would require to add an overload like this one:

template<typename... _Args>
void  construct(pointer p, _Args&&... __args)
{ ::new(p) _Tp(std::forward<_Args>(__args)...); }

which is c++11 specific. So we would need a portable way to detect if c++11 is enabled. Does any one know a good solution for this?
Comment 2 Christoph Hertzberg 2012-05-03 10:40:55 UTC
What is supposed to work and be portable is to check whether (__cplusplus>=201103L)

See here:
Comment 3 Christoph Hertzberg 2012-05-03 10:53:16 UTC
(In reply to comment #2)
> What is supposed to work and be portable is to check whether
> (__cplusplus>=201103L)

Which at least for gcc seems to work only starting from version 4.7, so you need to check at least for __GXX_EXPERIMENTAL_CXX0X__ as well:
Comment 4 Gael Guennebaud 2012-05-03 11:56:13 UTC
thanks, I'm tempted to check for   (__cplusplus>=201103L)  only. It's not our business to support experimental compiler features.
changeset:   ad274b0ede15
user:        ggael
date:        2012-05-03 11:55:30
summary:     bug 455: add support for c++11 in aligned_allocator
Comment 5 Christoph Hertzberg 2012-05-03 12:18:06 UTC
I would suggest defining a token such as EIGEN_CXX11_ENABLED in Macros.h if c++11 is available. That will make it easier to adapt in case the official way is not portable at all (has anyone checked MSVC for instance?) and also gives people an easier possibility to manually enable it, if they use gcc<4.7.
I assume there will be more use cases in the future such as l-value references.
Comment 6 Gael Guennebaud 2012-05-03 17:45:31 UTC
Yes that would be better. We could also check how Boost is dealing with that. They probably has good macros to detect each c++11 features.

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