What is the meaning of ‘const’ at the end of a member function declaration?

When you add the const keyword to a method the this pointer will essentially become a pointer to const object, and you cannot therefore change any member data. (Unless you use mutable, more on that later). The const keyword is part of the functions signature which means that you can implement two similar methods, one … Read more

What is std::move(), and when should it be used and does it actually move anything?

1. “What is it?” While std::move() is technically a function – I would say it isn’t really a function. It’s sort of a converter between ways the compiler considers an expression’s value. 2. “What does it do?” The first thing to note is that std::move() doesn’t actually move anything. It changes an expression from being … Read more

What does “cv-unqualified” mean in C++?

There are fundamental types and compound types. Fundamental types are the arithmetic types, void, and std::nullptr_t. Compound types are arrays, functions, pointers, references, classes, unions, enumerations, and pointers to non-static members. A cv-unqualified type is any of those types. For any cv-unqualified type, there are three corresponding cv-qualified types: const-qualified – with the const cv-qualifier … Read more

shared_from_this causing bad_weak_ptr

John Zwinck’s essential analysis is spot on: The bug is that you’re using shared_from_this() on an object which has no shared_ptr pointing to it. This violates a precondition of shared_from_this(), namely that at least one shared_ptr must already have been created (and still exist) pointing to this. However, his advice seems completely beside the point … Read more