News for hackers. Stuff that matters.
Re:C++ Patterns: The Badge by nisuni on Tuesday June 11, 2019 @05:52PM (#20159854)
How can {} return a Badge object? Some kind of operator overload?
Re:C++ Patterns: The Badge by cjhanks on Tuesday June 11, 2019 @06:02PM (#20159918)
It's bracket initialization of a struct, in this case the struct has no variables - the type is implicit from the method declaration.
Re:C++ Patterns: The Badge by eMSF on Tuesday June 11, 2019 @06:56PM (#20160259)
While it makes no difference in this case, it's worth noting that Badge<T> is not an aggregate type because it has a user-provided constructor. Therefore the object is value initialized, i.e. the braces are equivalent to 'Badge<Device>()'.

edit: what this means is that even if the struct had data members, you couldn't brace initialize it like an aggregate type, and to achieve something syntactically similar, you would need a suitable constructor.

Re:C++ Patterns: The Badge by antisemiotic on Tuesday June 11, 2019 @05:53PM (#20159865)
Brace initialization, I suppose.