std::cin.ignore in template function

Hi, I tried to create this function for reading from cin into any type of argument. I dont know if it must be done in this situation but i tried to ignore the rest of the stream and setting cin state back to good in case bad value was entered. Also giving back the original value (is that actually necessary after failed cin >> ?)

But i couldn't compile this. There are the errors i was getting :

Error	1	error C2955: 'std::numeric_limits' : use of class template requires template argument list
Error	2	error C1903: unable to recover from previous error(s); stopping compilation


Whats the problem here?

1
2
3
4
5
6
7
8
9
10
11
template<class T>
void read_val(T& v){
	T temp = v;
	std::cin >> v;
	if (!std::cin){
		std::cout << "Bad value entered\n";
		std::cin.clear();
		std::cin.ignore(std::streamsize<std::numeric_limits>::max(), '\n');
		v = temp;
	}
}
You switched streamsize and numeric_limits.
To add to@fg109. Should be std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
Ohh, tnx guys :)
Topic archived. No new replies allowed.