implement pair/tuple input
This commit is contained in:
parent
e3f3f6470d
commit
9709a35f46
|
@ -27,8 +27,7 @@ signed main() {
|
|||
a.foo();
|
||||
a.bar(3,4,"hi");
|
||||
|
||||
int i = read_int();
|
||||
int j = read_int();
|
||||
auto [i, j] = read<int, int>();
|
||||
print(i, j);
|
||||
|
||||
print("read string",read<string>());
|
||||
|
|
|
@ -10,6 +10,15 @@ T read() {
|
|||
return x;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
std::pair<T1, T2> read() {
|
||||
return std::pair<T1, T2>{read<T1>(), read<T2>()};
|
||||
}
|
||||
template <typename T1, typename T2, typename T3, typename... Ts>
|
||||
std::tuple<T1, T2, T3, Ts...> read() {
|
||||
return std::tuple<T1, T2, T3, Ts...>{read<T1>(), read<T2>(), read<T3>(), read<Ts>()...};
|
||||
}
|
||||
|
||||
int read_int() { return read<int>(); }
|
||||
char read_char() { return read<char>(); }
|
||||
double read_double() { return read<double>(); }
|
||||
|
|
Loading…
Reference in New Issue