Sorry for the bad title to this question, but I really couldn't think of a better way to title it. My question involves structured bindings and maps, but couldn't really find anything in the standard that could give me a cast-iron guarantee. Consider the following:-
struct Obj {};
std::map<int, Obj> data;
if (const auto&[o, state] = data.insert(std::make_pair(0, Obj())); state)
{
// state is true if the object was inserted
}
else
{
// Is it guaranteed that Obj() won't get called for a case where the key already exists?
// Does the key get checked for its existence BEFORE the evaluation of the make_pair()?
}
At what point is the key evaluated for its existence, or is this a case of everything will be evaluated from the inside to the outside (so Obj() created, then make_pair(), then .insert attempted etc.