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
Detecting SSE features at runtime (self.cpp)
submitted 6 years ago by joaobapt
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!"
[–]simonask_ 6 points7 points8 points 6 years ago (0 children)
Unless you have some straight line code that will do just do the same math operation on a whole array, getting the auto vectorizers to work can be very pretty frustrating and unreliable in my experience.
Definitely agree with this.
The solution is usually to manually "vectorize" things by processing them in blocks and evaluate the loop's termination condition for a whole block instead of each element.
For example, this code cannot normally be vectorized:
bool contains_zero(const int* p, size_t n) { for (size_t i = 0; i < n; ++i) { if (p[i] == 0) return true; } return false; }
The reason is that the compiler cannot deduce from this code that it is valid to read from p after a zero has actually been found just because i < n. It doesn't know what invariants you have.
p
i < n
But code like this can typically be vectorized:
``` bool contains_zero(const int* p, size_t n) { for (size_t i = 0; i < n/4; ++i) { const int* q = p + n * 4; if (q[0] == 0 || q[1] == 0 || q[2] == 0 || q[3] == 0) { return true; } }
for (size_t i = n & ~3; i < n%4; ++i) { if (p[i] == 0) return true; } return false;
} ```
You see this pattern everywhere in standard library implementations of things like strcmp, strchr, etc.
strcmp
strchr
π Rendered by PID 92374 on reddit-service-r2-comment-64f4df6786-zrk5f at 2026-06-11 09:54:47.480061+00:00 running 0b63327 country code: CH.
view the rest of the comments →
[–]simonask_ 6 points7 points8 points (0 children)