Where do I find the current C or C++ standard documents?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. For many questions the answer seems to be found in “the standard”. However, where do we find that? Preferably online. Googling can sometimes feel futile, again especially for the C standards, since … Read more

What is this weird colon-member (” : “) syntax in the constructor?

Recently I’ve seen an example like the following: #include <iostream> class Foo { public: int bar; Foo(int num): bar(num) {}; }; int main(void) { std::cout << Foo(42).bar << std::endl; return 0; } What does this strange : bar(num) mean? It somehow seems to initialize the member variable but I’ve never seen this syntax before. It … Read more

Resolve build errors due to circular dependency amongst classes

I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else 🙂 ) which lead to circular dependencies between C++ classes in different header files (can happen also in the same file). But fortunately(?) this doesn’t happen often … Read more

What are copy elision and return value optimization?

What is copy elision? What is (named) return value optimization? What do they imply? In what situations can they occur? What are limitations? If you were referenced to this question, you’re probably looking for the introduction. For a technical overview, see the standard reference. See common cases here. 5 Answers 5 Introduction For a technical … Read more

What’s the difference between “STL” and “C++ Standard Library”?

Someone brought this article to my attention that claims (I’m paraphrasing) the STL term is misused to refer to the entire C++ Standard Library instead of the parts that were taken from SGI STL. (…) it refers to the “STL”, despite the fact that very few people still use the STL (which was designed at … Read more

C++11 rvalues and move semantics confusion (return statement)

I’m trying to understand rvalue references and move semantics of C++11. What is the difference between these examples, and which of them is going to do no vector copy? First example std::vector<int> return_vector(void) { std::vector<int> tmp {1,2,3,4,5}; return tmp; } std::vector<int> &&rval_ref = return_vector(); Second example std::vector<int>&& return_vector(void) { std::vector<int> tmp {1,2,3,4,5}; return std::move(tmp); } … Read more