top | item 45154357

(no title)

sgsjchs | 5 months ago

If the moves were destructive, I'd design it to have the default constructor call `::socket` and destructor call `::close`. And there wouldn't be any kind of "closed" state. Why would I want it?

discuss

order

spacechild1|5 months ago

Your socket class would have no default constructor? And you would never want to close the socket before the object's lifetime ends? Really?

sgsjchs|5 months ago

In this case, I would want the address family and protocol to be statically known, so it would have default constructor. But for example, a file might not have one, sure. As for closing before lifetime ends, why? I can just end lifetime. Wrap it in an optional if the type system can't figure it out like with a struct member.

7jjjjjjj|5 months ago

With destructive moves, you can end an object's lifetime whenever you want.