This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 455 - aligned_allocator error with gnu++0x flag
Summary: aligned_allocator error with gnu++0x flag
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:
Depends on:
Blocks:
 
Reported: 2012-04-26 21:59 UTC by daviddoria
Modified: 2019-12-04 11:37 UTC (History)
3 users (show)



Attachments

Description daviddoria 2012-04-26 21:59:55 UTC
I have posted the full demonstration here:
http://forum.kde.org/viewtopic.php?f=74&t=101773

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:
http://sourceforge.net/apps/mediawiki/predef/index.php?title=Standards
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:
http://stackoverflow.com/questions/2958398/gnu-c-how-to-check-when-std-c0x-is-in-effect
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.

https://bitbucket.org/eigen/eigen/changeset/ad274b0ede15/
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.
Comment 7 Nobody 2019-12-04 11:37:49 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/455.

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