Created
September 29, 2020 09:23
-
-
Save Aloxaf/a4defed8e5800804a0d86490cf093bf3 to your computer and use it in GitHub Desktop.
C++ qread
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
#include <cstdio> | |
#include <iostream> | |
#include <string> | |
#include <tuple> | |
template <typename... Ts> | |
std::tuple<Ts...> qread() | |
{ | |
return std::tuple<Ts...>{ ([]() -> Ts { Ts t; std::cin >> t; return t; })()... }; | |
} | |
int main(void) | |
{ | |
auto [a, b, c] = qread<int, float, std::string>(); | |
printf("=> %d %f %s", a, b, c.c_str()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment