When can auto deduce undesired types?
Show answer and explanation
auto preserves the initializer's actual expression type, which can be an invisible proxy such as std::vector<bool>::reference rather than bool. Force the intended value type when a proxy could outlive its owner or expose surprising behavior.
auto preserves the initializer's actual expression type, which can be an invisible proxy such as std::vector<bool>::reference rather than bool. Force the intended value type when a proxy could outlive its owner or expose surprising behavior.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.