▲ | spacechild1 3 days ago | ||||||||||||||||||||||||||||||||||
> The same difference as making pointers always non-nullable and reintroducing nullability via an optional wrapper only when semantically appropriate. 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. | |||||||||||||||||||||||||||||||||||
▲ | sgsjchs 3 days ago | parent [-] | ||||||||||||||||||||||||||||||||||
> 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. Technically you can, but it's unreasonable to create an os-level socket just to put into the moved-out object where it will be immediately destroyed again. This is not an issue when the moves are destructive. > 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. That's not true. The sentinel value need not be exposed in the public interface of the class, it can only be accessible via the customization point of the optional. | |||||||||||||||||||||||||||||||||||
|