Re: [eigen] a few things

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


> My concern here is the following. Suppose that at some point during 
> compilation, the compiler has decided that the underlying integer type 
> for "enum Size" is "char"  (this counts as an integer type, right?)
> 
> Suppose then (unlikely but possible) that later the compiler finds in the 
> source code an instanciation like
> 
> Matrix<float, 128, 1> myBigFixedSizeVector;
> 
> 128 doesn't fit into char so what happens?
> - compiler error?
> - integer overflow / undefined behavior?
> - or is the compiler so clever that it will first go through the whole source 
> code to see what integer type is really needed?
> 
> (Well I ask about the compiler but what I really care about is the C++ 
> standard i.e. I don't want to use non-standard behavior)
> 
> Is it a good idea, to work around this issue, to declare enum Size as follows?
> enum Size { Dynamic = -1, Generic = -2, Dummy = INT_MAX };
> in order to ensure that the underlying type is "int" ?

I don't know about the rest of the questions but
stroustrup agrees with you here. Section 4.8.
I think you'll be safe anyway because there is always an implicit conversion operator from enum to
int. I think your template arguments have to be int so everything should be ok.

Cheers
Ben







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