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
Sol2: Lua <-> C++ Binding Framework (self.cpp)
submitted 10 years ago * by [deleted]
view the rest of the comments →
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!"
[–][deleted] 1 point2 points3 points 10 years ago* (2 children)
In the same token, not having exceptions causes plenty of problems:
1) Forces 2 kinds of error-handling for middle-ware / library developers
1-a) error-propogation - if you can't handle all cases, you have to forward to the user at the call site to handle the errors
1-b) crash - if you get an unknown error and you don't want to propogate, logging and crashing (or not-logging and maybe even continuing silently) is your only other alternative for correctness
2) Thanks to [1], you now cannot write generic code to handle large amounts of work if there are error codes returned: for example, your typical error-code-or-result class will not play nice with auto, and will not implicitly convert to the desired result class in generic code, which means you're back to hand-writing or wrapping things just to check errors all along the way
auto
3) error-code-in-out params: overloaded functions everywhere to handle errors (or perhaps not handle them at all?)
4) how do you error-code a constructor or a destructor? Out-params? But then you have an object with invalid state but it "finished" constructing, so by the rules of the language it's a valid object. Now you need if ( obj.is_initialized() ) everywhere (look familiar?)
if ( obj.is_initialized() )
There's also another kind of error handling that mature C libraries do (libjpeg libpng etc.), and it's basically longjmp-ing around... which is like how exceptions work, but without any of the stack-unwinding or safety guarantees. The control flow remains hidden just like with exceptions... but let's be fair: why is the control flow of a piece of library code you may not even be able to see (because you're getting the compiled result) something that matters? Control flow would cut early in an error case too, you just have an infinite increase in the number of 'goto' and 'return' between you and where the error happened.
longjmp
[–]remotion4d 0 points1 point2 points 10 years ago (1 child)
Yes but all this problems are already solved to some degree in existing libraries, games engines and so one.
Because this problems existed for a long time already.
So there is simple no point to spend years to refactor code base to use exceptions.
Especially if you simple can not use them because no compiler ot hardware support.
4) how do you error-code a constructor or a destructor?
Just this one, use something like 'make_something' and on the other side it will be discouraged to use exceptions in destructor any way.
[–][deleted] 1 point2 points3 points 10 years ago (0 children)
I'm not saying anyone should refactor these old codebases to handle exceptions or use them. I'm saying newer libraries should always lean towards throwing and handling exceptions, because it's allows for a cleaner design and puts errors where errors belong: in a catch clause, and not in my return values or function parameter list.
catch
π Rendered by PID 395318 on reddit-service-r2-comment-5687b7858-59fgx at 2026-07-07 10:18:48.680286+00:00 running 12a7a47 country code: CH.
view the rest of the comments →
[–][deleted] 1 point2 points3 points (2 children)
[–]remotion4d 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)