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

286 views Asked by At
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

2

There are 2 answers

7
Edgar Rokjān On BEST ANSWER

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

...

4
paweldac On

Well, it doesn't evaluate to false, it evaluates to true:

#include <iostream>
#include <limits>

int main() {
    std::cout << std::boolalpha << std::numeric_limits<volatile int>::is_integer << std::endl;
    return 0;
}

https://ideone.com/y3ne6Y