#include <iostream>
#include <string>
// This function returns a struct containing three values.
// The struct is defined *inside* the function, which is allowed in C++.
// The return type is deduced automatically using 'auto'.
auto f() {
// Local struct definition
struct values {
int a, b; // two integers
std::string s; // one string
};
// Return an instance of the struct using brace initialization
return values{12, 837, "c++"};
}
int main() {
// Structured binding: C++17 feature.
// It "unpacks" the returned struct into three separate variables.
auto [value1, value2, value3] = f();
std::cout << value1 << ", " << value2 << ", " << value3;
}
/*
run:
12, 837, c++
*/