Defining variables in control structures
问题 According to the standard, what is the difference in behavior between declaring variables in control structures versus declaring variables elsewhere? I can't seem to find any mention of it. If what I'm referring to isn't clear, here's an example: if (std::shared_ptr<Object> obj = objWeakPtr.lock()) As you can see, I'm declaring and initializing a local variable, obj , in the if block. Also, is there any technical reason as to why this syntax isn't given any special behavior when used in place