Re:Bjarne Stroustrup: “I Did It for You All” (2007)
by __s on Wednesday December 08, 2021 @12:28PM
(#29487666)
I got to revisit C++ to port some code to boost::asio
It crashed because the object was deallocated by time the handler ran. So now I'm taking a shared_ptr parameter thisref parameter to keep "this" alive. Ideally it'd be a unique_ptr, but then my understanding is that ptr->func(std::move(ptr)) is undefined
It's nice if these sorts of details are compiler errors, but at least there were some compiler errors:
I ran into some issues over whether move being ambiguous for std::move. Took awhile figuring out where to get socket types for boost, between template parameters being duck typed & boost source being a tangle to read as documentation. Errors end up being in some header when the issue is my code somewhere passing the wrong thing
Got it all sorted out eventually, but glad to get back to C/Ruby/Go/Rust programming
It crashed because the object was deallocated by time the handler ran. So now I'm taking a shared_ptr parameter thisref parameter to keep "this" alive. Ideally it'd be a unique_ptr, but then my understanding is that ptr->func(std::move(ptr)) is undefined
It's nice if these sorts of details are compiler errors, but at least there were some compiler errors:
I ran into some issues over whether move being ambiguous for std::move. Took awhile figuring out where to get socket types for boost, between template parameters being duck typed & boost source being a tangle to read as documentation. Errors end up being in some header when the issue is my code somewhere passing the wrong thing
Got it all sorted out eventually, but glad to get back to C/Ruby/Go/Rust programming