31 const std::function<
bool(T)>& isValid,
32 const std::string& errorMessage)
39 if (!(std::cin >> value))
43 throw std::runtime_error(
"End of input stream reached.");
46 std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
47 std::cout <<
"Invalid input. Please enter a number." << std::endl;
54 std::cout << errorMessage << std::endl;
67 const std::function<
bool(
int)>& isValid,
68 const std::string& errorMessage);
79 const std::function<
bool(
double)>& isValid,
80 const std::string& errorMessage);