Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
spacechild1
59 days ago
|
parent
|
context
|
favorite
| on:
The repercussions of missing an Ampersand in C++ a...
How would I use such a socket class as a member variable? How do I reopen the socket?
sgsjchs
59 days ago
[–]
Reopen by constructing and assigning a new socket.
spacechild1
58 days ago
|
parent
[–]
So I essentially have to wrap it in something like std::optional. Well, that's certainly
one
way to write a socket class, but I'd say it's not idiomatic C++. (I have never seen a socket class being implemented like that.)
sgsjchs
58 days ago
|
root
|
parent
[–]
You don't need optional in this case, the assignment would just destroy the old socket and immediately move the new one in its place.
spacechild1
58 days ago
|
root
|
parent
[–]
Well, reopening a socket implies that I have manually closed the socket, which does require an optional with your implementation.
Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: