Skip to content

Instantly share code, notes, and snippets.

@Aloxaf
Created September 29, 2020 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aloxaf/a4defed8e5800804a0d86490cf093bf3 to your computer and use it in GitHub Desktop.
Save Aloxaf/a4defed8e5800804a0d86490cf093bf3 to your computer and use it in GitHub Desktop.
C++ qread
#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