Tag: move semantics

C++ curiosities: one does not simply move a const object

When I learned about the C++11 move semantics for the first time, it was mighty confusing to me. My mental model of moving something, as in “move a physical object from point A to point B”, was clearly not an adequate mental model for what C++11 calls “moving an object”. And one of the examples […]

C++ curiosities: move semantics, sizeof, areaof, and pointy types

This post continues the topic raised in “C++ curiosities: move semantics is not about moving”. Last time we’ve seen how a move operation can be split into 2 steps: “shallow copying” and “destructor disarmament”. This time I’ll show a way of using “areaof” to understand the benefits of move operations on a given type, and […]

C++ curiosities: move semantics is not about moving

C++ move semantics is not about moving, but about keeping as many things as possible where they already are. Yes, at a very high level of abstraction one can say that move semantics is about “moving ownership” of a resource from on object to another. But performance benefits of move semantics do not come from […]

C++ curiosities: std::move that doesn’t move

Despite its name, std::move doesn’t move anything. std::move is no more than a type cast. It has 2 major purposes in life: to return an “rvalue reference” to its argument and to mislead people into thinking it does more than that. In fact, you can call the bluff by calling static_cast<T&&> explicitly instead of std::move and […]

An inquiry into CPL values

Christopher Strachey and CPL are sometimes mentioned in the discussions of C++ value categories, though usually just briefly and for dubious reasons: C++ value categories are defined in a specific fashion different from Strachey’s blueprints, and some even say that the analogy is downright confusing. I’ve attempted to get a better understanding of the issue, and this post summarizes my findings. “The terms […]