#include <tuple>
#include <iostream>
#include <string>
std::tuple<double, char, std::string> get_info(int idx)
{
if (idx == 0) return std::make_tuple(3.14, 'X', "C++");
if (idx == 1) return std::make_tuple(2.89, 'Y', "Python");
if (idx == 2) return std::make_tuple(2.75, 'Z', "C#");
throw std::invalid_argument("invalid idx");
}
int main()
{
auto info = get_info(0);
std::cout << "INDEX: 0, "
<< "double: " << std::get<0>(info) << ", "
<< "char: " << std::get<1>(info) << ", "
<< "string: " << std::get<2>(info) << std::endl;
double d;
char ch;
std::string s;
std::tie(d, ch, s) = get_info(1);
std::cout << "INDEX: 0, "
<< "double: " << d << ", "
<< "char: " << ch << ", "
<< "string: " << s << std::endl;
return 0;
}
/*
run:
INDEX: 0, double: 3.14, char: X, string: C++
INDEX: 0, double: 2.89, char: Y, string: Python
*/