How to elegantly return an object that is default-initialized?
问题 I have a class like below: class VeryVeryVeryLongTypeName { bool is_ok; VeryVeryVeryLongTypeName() : is_ok(false) {} }; VeryVeryVeryLongTypeName f() { VeryVeryVeryLongTypeName v; ... // Doing something if (condition_1 is true) { return v; } else { return VeryVeryVeryLongTypeName(); } ... // Doing something if (condition_2 is true) { return v; } else { return VeryVeryVeryLongTypeName(); } } I think the statement return VeryVeryVeryLongTypeName(); is very tedious and ugly, so, my question is: