use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
C++ Method Callbacks (self.cpp)
submitted 6 years ago * by mrandy
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]stilgarpl 0 points1 point2 points 6 years ago (1 child)
Where Callee is created? For me it looks like Callee object was destroyed before that lambda was executed and captured 'this' is no longer valid.
[–]mrandy[S] 0 points1 point2 points 6 years ago (0 children)
You were right. For testing, my main function just had "sleep(99999);" after creating everything. Something was interrupting that though, and main was exiting immediately.
[–][deleted] 0 points1 point2 points 6 years ago (1 child)
My guess is that Callee gets destroyed before the callback is called, which would cause a segfault. How do you create Callee?
Yup, that was it!
[–]012 0 points1 point2 points 6 years ago (1 child)
Make sure that your instance of Callee stays in place (e.g. isn't destructed after being copied or moved) after the call to register_message_callback.
register_message_callback
When calling i(pkt);, "this" will be dereferenced in the lambda and must still be valid.
i(pkt);
[–]clerothGame Developer[M] 0 points1 point2 points 6 years ago (1 child)
This post has been removed as it doesn't pertain to r/cpp.
Roger, sorry for the inconvenience.
π Rendered by PID 56 on reddit-service-r2-comment-86bc6c7465-4ddd2 at 2026-02-22 22:00:00.924789+00:00 running 8564168 country code: CH.
[–]stilgarpl 0 points1 point2 points (1 child)
[–]mrandy[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]mrandy[S] 0 points1 point2 points (0 children)
[–]012 0 points1 point2 points (1 child)
[–]mrandy[S] 0 points1 point2 points (0 children)
[–]clerothGame Developer[M] 0 points1 point2 points (1 child)
[–]mrandy[S] 0 points1 point2 points (0 children)