In JavaScript ES6, there is a language feature known as destructuring. It exists across many other languages as well.
In JavaScript ES6, it looks like this:
Mostly there with std::map and std::tie:
std::map
std::tie
#include #include #include using namespace std; // an abstact object consisting of key-value pairs struct thing { std::map kv; }; int main() { thing animal; animal.kv["species"] = "dog"; animal.kv["sound"] = "woof"; auto species = std::tie(animal.kv["species"], animal.kv["sound"]); std::cout << "The " << std::get<0>(species) << " says " << std::get<1>(species) << '\n'; return 0; }