Search code examples
c++stdvolatilenumeric-limits

Why std::numeric_limits::is_integer is false for volatile types?


std::numeric_limits<volatile int>::is_integer

evaluates to 'false'.

But why? Isn't a volatile int still an integer type? I want to know if there is some kind of deep meaning in this.

UPD: Compiler is armcc from Keil 4.72


Solution

  • You are (or, may be, your compiler) wrong here because it should be true.

    From numeric_limits page:

    Additionally, a specialization exists for every cv-qualified version of each arithmetic type, identical to the unqualified specialization, e.g. std::numeric_limits< const int >, std::numeric_limits< volatile int >, and std::numeric_limits< const volatile int > are provided and are equivalent to std::numeric_limits< int >.

    And from numeric_limits/is_integer page:

    Standard specializations:

    ...

    int true

    ...