std::tuple と std::tie と std::ignore を調べた

複数の型の値を保存するクラス : std::tuple
#include <tuple>
#include <string>
#include <iostream>
int main(void)
{
    std::tuple<int,float,std::string> t(1,2.5,"Hello");
    std::cout << "0:" << std::get<0>(t) << std::endl;
    std::cout << "1:" << std::get<1>(t) << std::endl;
    std::cout << "2:" << std::get<2>(t) << std::endl;
}
0:1
1:2.5
2:Hello
要素をまとめて取り出すための std::tie
#include <tuple>
#include <string>
#include <iostream>
int main(void)
{
    std::tuple<int,float,std::string> t(1,2.5,"Hello");
    int a;
    float b;
    std::string c;
    std::tie(a,b,c) = t;
    std::cout << "a:" << a << std::endl;
    std::cout << "b:" << b << std::endl;
    std::cout << "c:" << c << std::endl;
}
a:1
b:2.5
c:Hello
取り出す時、特定要素を無視するプレースホルダ std::ignore
#include <tuple>
#include <string>
#include <iostream>
int main(void)
{
    std::tuple<int,float,std::string> t(1,2.5,"Hello");
    int a;
    std::string c;
    std::tie(a,std::ignore,c) = t;
    std::cout << "a:" << a << std::endl;
    std::cout << "c:" << c << std::endl;
}
a:1
c:Hello