New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
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: 2011-05-16 10:52 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)).

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