c++ - Assigning an enum a max value via numeric_limits? -
i'm having trouble assigning element in enuma max value. first:
protected: enum {default_padding=std::numeric_limits<enum>::max()}; results in:
./basecode.h:30:51: error: expected identifier or '{' enum {default_padding=std::numeric_limits<enum>::max()}; ^ ./basecode.h:30:59: error: expected type enum {default_padding=std::numeric_limits<enum>::max()}; (and couple of others) second, switching to:
protected: enum {default_padding=std::numeric_limits<unsigned int>::max()}; results in:
./basecode.h:30:27: error: expression not integral constant expression enum {default_padding=std::numeric_limits<unsigned int>::max()}; how have numeric_limits give me value can use @ compile time enum?
the library older, supports lot of older compilers , ides. need @ least c++03 , preferably c++98.
and standard caveats apply: simple make based project. not use autotools, not use cmake, not use boost, etc.
in c++03, std::numeric_limits<t>::max() static. in c++11, became static constexpr. need latter in order used in integral constant expression, compiling -std=c++11 do.
if can't use c++11, can use uint_max.
Comments
Post a Comment