Using numeric_limits::max() in constant expressions

前端 未结 5 856
無奈伤痛
無奈伤痛 2020-12-10 11:04

I would like to define inside a class a constant which value is the maximum possible int. Something like this:

class A
{
    ...
    static const int ERROR_V         


        
5条回答
  •  鱼传尺愫
    2020-12-10 11:14

    Looks like a bit of a defect...

    In C++0x, numeric_limits will have everything marked with constexpr, meaning you will be able to use min() and max() as compile-time constants.

提交回复
热议问题