Created
June 10, 2017 04:53
-
-
Save denniskupec/13bb0a6f729d4f1d9a75a99ad05a4879 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 2017 Dennis Kupec | MIT License */ | |
#include <iostream> | |
#include <functional> | |
#include <string> | |
#define Str(s) std::to_string(s) | |
using namespace std; | |
template <typename T> T get_input(const string msg); | |
template <typename T> T get_input(const string msg, function<bool(string)> verify); | |
template <typename T> T get_input(const string msg) | |
{ | |
T in; | |
do { | |
cout << msg; | |
getline(cin, in); | |
} | |
while (cin.fail()); | |
return in; | |
} | |
template <typename T> T get_input(const string msg, function<bool(string)> verify) | |
{ | |
T in; | |
do { | |
cout << msg; | |
getline(cin, in); | |
} | |
while (cin.fail() || !verify(in)); | |
return in; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment