3 ms·
The return-type overloading helps if you want to use non-static member initialization: struct Foo { int x = init("x"); double y = init("y");
by gpderetta 6y ago
The return-type overloading helps if you want to use non-static member initialization:
struct Foo {
int x = init("x");
double y = init("y");
string z = init("z");
};
for not very good reasons you can't use auto there and having to specify the type twice is ugly.
edit: this is pretty much the only case I have used this trick.
- ot 6y agoYeah, this is something that might have made sense before auto, and in fact IIRC there were some Boost libraries that used this trick (Boost.Assign?), but it's just unnecessary complication at this point.