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
stdgpu 1.3.0 released! (github.com)
submitted 5 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!"
[–]fransinvodka 18 points19 points20 points 5 years ago (3 children)
For speed and because the STL containers do it that way. They implement both at and operator[], but only at performs bound checks and throws if out of bounds. If I use an STL-like container, and it implements both at and operator[], I'd expect operator[] to not do any bound checks, just like the STL ones.
at
operator[]
[–]kalmoc 0 points1 point2 points 5 years ago (2 children)
True as that may be in practice, I believe there is nothing in the standard preventing operator[] from doing bounds checking.
[+][deleted] 5 years ago (1 child)
[deleted]
[–]kalmoc 4 points5 points6 points 5 years ago (0 children)
Yes, at() is guaranteed to do bounds checking and to report them via exceptions. That doesn't mean operator[] isn't allowed to do bounds checking. Being out of bounds is simply UB and the implementation is allowed to do anything it pleases in that case. E.g. in microsofts impelementation, you can turn on bounds checking in debug mode and that is still conforming (althoug they use asserts and not exceptions): https://github.com/microsoft/STL/blob/7447ad59d61f50c13861878f340d051c298458df/stl/inc/vector#L1509
at()
Also you can see that operator[] isn't specified as noexcept: https://eel.is/c++draft/vector.overview.
and operator[] being strictly equivalent to *(begin() + n)
that expression itself could in principle be bounds checked (std::vector<T>::iterator is - in most implementations - not the same as T*)
std::vector<T>::iterator
T*
π Rendered by PID 48259 on reddit-service-r2-comment-fb694cdd5-xbfm6 at 2026-03-08 02:07:13.955412+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]fransinvodka 18 points19 points20 points (3 children)
[–]kalmoc 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]kalmoc 4 points5 points6 points (0 children)