I don't know how to better phrase my question, since it's the first time encountering this. Basically I have a function and inside this function an anonymous function is called(a lambda).
std::ostream& Print(std::ostream& os){
/*
some code
*/
classMember.doSmth([&](std::size_t num){
auto [var1, var2] = classMember.funcThatReturnsATupple(num) // <- this I don't understand
});
}
void doSmth(const std::function<void(std::size_t num)>& function) const{
//does stuff
}
var1 and var2 are not declared anywhere in Print(). I'm only allowed to declare them in doSmth(), but i don't quite understand what they are, nor how they work. Is the following somewhat equivalent to auto [var1, var2] = classMember.funcThatReturnsATupple(num)?
auto var1 = classMember.funcThatReturnsATupple(num);
auto var2 = classMember.funcThatReturnsATupple(num);
auto [var1, var2] calls a function which return a tuple, which has two elements(std::tuple<int, int>). Does the fist value of the tuple get stored in var1 and the second one in var2? I get the error that var1 and var2 are not declared. Do I need to declare them in doSmth()?