Skip to content

Instantly share code, notes, and snippets.

@Aloxaf
Created Sep 29, 2020
Embed
What would you like to do?
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