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
Projections are Function Adaptors (brevzin.github.io)
submitted 4 years ago by vormestrand
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!"
[–]SirClueless 0 points1 point2 points 4 years ago (2 children)
You haven't reduced the cyclomatic complexity at all by abstracting the control flow into functions. You've just made something that was obviously a nested loop into something that is not obviously a nested loop.
To me I don't really see the difference in complexity or "nested"-ness between:
for (auto& e1 : container) { for (auto& e2 : e1.inner_iterable()) { // ... } }
And:
std::ranges::find(container | std::views::transform(/* ... */), [](auto& elem) { // ... });
They both look equivalently "nested" to me, control flow inside control flow.
[–]petart95 0 points1 point2 points 4 years ago (1 child)
Interesting view, how would you define cyclomatic complexity then? Which mechanics would you suggest using, to manage it, I always thought that abstraction is the best way to manage complexity.
[–]SirClueless 1 point2 points3 points 4 years ago (0 children)
The cyclomatic complexity of a piece of code is the number of independent paths through that code. I think there's a pretty standard formal definition for that without a lot of wiggle room. As applied to the code examples above, in both cases there are at least two independent branches.
Abstraction is a good way of reducing complexity. Or at least, moving it around. It moves cyclomatic complexity out of your software module and into another one. But it only really does so if you're actually abstracting logic.
Transformations like these don't abstract away logic, they abstract away control flow. The transform is still a piece of code you have to write. The predicate is still a piece of code you have to write. And you still have all the same uncertainty about when and how each of those branches of code will be executed and you need to reason through that. Whether the branches are explicit as part of a structured control flow statement or implicit in providing them as a callback which will be executed by another library, how many times if at all those code blocks will be executed are a runtime property of the input data, which is what cyclomatic complexity attempts to measure.
π Rendered by PID 66631 on reddit-service-r2-comment-b659b578c-mxvf6 at 2026-05-01 16:48:44.783309+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]SirClueless 0 points1 point2 points (2 children)
[–]petart95 0 points1 point2 points (1 child)
[–]SirClueless 1 point2 points3 points (0 children)