Skip to content

Instantly share code, notes, and snippets.

@JPenuchot
Created July 19, 2018 09:32
Show Gist options
  • Save JPenuchot/995fda1e9a0a762f854a1811dc928858 to your computer and use it in GitHub Desktop.
Save JPenuchot/995fda1e9a0a762f854a1811dc928858 to your computer and use it in GitHub Desktop.
Example of C++ std::tuple pretty printer using parameter packs
#include <tuple>
#include <iostream>
int main()
{
// Creates a tuple<float, int, std::string> object
auto tup = std::make_tuple(1.f, 10, "Hello !");
// Apply the lambda with the members
// of the tuple as arguments
std::apply([](auto&... e)
{
// Parameter pack expansion
( (std::cout << e << '\n') , ... );
}, tup);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment