This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 263 - Anonymous enums not usable enough
Summary: Anonymous enums not usable enough
Status: NEW
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 2.x
Hardware: All All
: --- Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-09 16:51 UTC by Marc
Modified: 2019-12-04 10:43 UTC (History)
2 users (show)



Attachments

Description Marc 2011-05-09 16:51:35 UTC
#include <Eigen/Dense>
template<class T>void f(T const& t){ }
int main()
{
	f(Eigen::Vector3d::SizeAtCompileTime);
}

This fails to compile with Intel's compiler and produces a warning with clang. Note that the following causes the same error:

enum { a=0 }; f(a);

but not this:

enum dummy { b=0 }; f(b);

I hit this when calling std::min with this argument (no, not with Vector3d, with a template matrix type).
Comment 1 Gael Guennebaud 2011-05-11 08:37:32 UTC
hm ok. but maybe for such use cases it is probably better to cast the enum to int anyway:
f(int(Eigen::Vector3d::SizeAtCompileTime));
Comment 2 Marc 2011-05-16 10:52:52 UTC
(In reply to comment #1)
> hm ok. but maybe for such use cases it is probably better to cast the enum to
> int anyway:
> f(int(Eigen::Vector3d::SizeAtCompileTime));

Well, it is better to cast with the current implementation, but as a user it is fairly confusing that you have to do it at all. I am not asking you to change it, just making sure you are aware that this syntax means we have to write:
std::min(static_cast<int>(Vec1::SizeAtCompileTime),static_cast<int>(Vec2::SizeAtCompileTime)).
Comment 3 Nobody 2019-12-04 10:43:17 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/263.

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