Skip to content

Instantly share code, notes, and snippets.

@chrisjurich
Created August 23, 2020 17:52
Show Gist options
  • Save chrisjurich/295d61433f35982fadb181f1790d270c to your computer and use it in GitHub Desktop.
Save chrisjurich/295d61433f35982fadb181f1790d270c to your computer and use it in GitHub Desktop.
#include<tuple>
#include<vector>
#include<map>
#include<iostream>
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// NOTE: you have to pass the flag "-std=c++17" to the compiler.
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
using TUPLE = std::tuple<int,int,int,int,int>;
using TUPLES = std::vector<TUPLE>;
int main() {
auto M = std::map<int,int>{{1, 2},
{3,4},
{5,6}};
for(auto& [F,S] : M ) {
std::cout<<F<<"\t"<<S<<std::endl;
}
auto T = TUPLES{
{1,2,3,4,5},
{10,20,30,40,50},
};
for(auto& [first,second,third,fourth,fifth] : T) {
std::cout<<first<<"\t"<<second<<"\t"<<third<<"\t"<<fourth<<"\t"<<fifth<<std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment