|
|
|
|
|
by sgsjchs
277 days ago
|
|
> what difference would it make The same difference as making pointers always non-nullable and reintroducing nullability via an optional wrapper only when semantically appropriate. > what could you possibly do with an arbitrary user-defined class Just add some customization points to std::optional so that users can define which value of the class to treat as noneopt internally. |
|
Again, I don't see what this has to do with destructive moves. If you want a socket class that always refer to an open socket, you can already do that. Same for non-nullable pointer wrappers. Conversely, destructive moves don't prevent you from implementing a socket class with a close() method. These concepts are really orthogonal.
> Just add some customization points to std::optional so that users can define which value of the class to treat as noneopt internally.
How is this supposed to work? The very point of your socket class is that it always contains a valid socket handle. Once you introduce a sentinel value, you are back to square one. If the optional class is able to construct a socket with the sentinel value, so is the user.