blob: 9a2ca645acb65f6f358b669da6d003295bdb1fcf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#ifndef GS_CLI
#define GS_CLI
#include <iostream>
#include <limits>
namespace cli {
template <typename T>
void readUserInput(T& outValue, const char* enter_message, const char* error_message) {
do {
std::cout << enter_message;
std::cin >> outValue;
if (std::cin.fail()) {
std::cerr << error_message << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
continue;
}
break;
} while (true);
}
}
#endif /* GS_CLI */
|