Expected identifier with numeric_limits

I'm trying to perform a simple input operation, and check to make sure that whatever the user input is a valid input (is within data type bounds, is correct data type...). But when I get to ignoring the input, I keep getting an error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
unsigned short num;

while (true)
{
     std::cin >> num;

     if (std::cin.fail())
     {
          num = 1;
          std::cout << "Error" << std::endl;

          std::cin.clear();

          std::cin.ignore(std::numeric_limits<unsigned short>::max/*Error: expected an identifier*/(), '\n');
     }
}


I don't fully understand why this error is here. I'm writing things just as they are on the tutorial.
If someone could help me out, that would be much appreciated.
Microsoft had a bad day and defined lowercase min and max macros in their Windows.h header.
1
2
#undef min
#undef max 
Or:

#define NOMINMAX
Last edited on
@xismn That's no good in header files as Windows.h will have already been included.
Last edited on
1
2
3
4
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <windows.h> 
@Duoas
1
2
#include <Windows.h>
#include <YourHeader.h> 
What now?
Last edited on
Works like a charm. Thanks guys :)
Topic archived. No new replies allowed.