From my perspective, the committee seemed urgent to standardize what the
'move ctor' means. Like always(?), the committee likes to show it always has a
better resolution (unproven, e.g. std::endl) then requested.
General rule: Complexity don't go away.
C++ statement can be shorter (or smarter, whatever), but the 'hidden' comments
become longer, the 'comment' can be shorter if put into 'standard'. To understand
'standard', one has to expand 'comment' to, say, ordinary/original form...
... Complexity is just moved around, won't disappear. (another case is in the error handling).
The rule applies to almost anything. IMO, the goal should be 'efficiency'.
Snippet of the manpage of the move ctor for template class Array (written before 2006):
No issues of rref. The only problem encountered is with classes like BigInt
BitInt::operator=(T) when T is arithmetic types, lots of overloads are needed.
But such needs are never demanding enough (IMO) for a core language change
to add rref.
Array(Array& src, ByMove_t)
Move semantics of src to this pointed address.
After function completed, src is regarded non-existant.
The space occupied by src can be recycled. The dummy argument type
ByMove_t acts as a function signature, use instance should always
be ByMove. This member is supposed to be invoked only via
placement new or in member initialization list, not to be
explicitly called otherwise.
This member is not entirely a real constructor (no new object is
ever created, so it is called move) but a function in constructor
form to support object movement in a dynamic array.
Note: Except in member initialization list, src must be
a whole type, not reference to a base. Otherwise,
effect is undefined.
Note: In cases element type T is a class that can use ::memcpy(2)
to do the job, user needs to provide a template
Wy::TypeTrait<T> overload, e.g.
template<> struct Wy::TypeTrait<T> {
static constexpr bool memcpy_able=true;
static constexpr bool memset_able=false;
};
[Effect]
size()= src.size()
capacity()= src.capacity()
begin()= src.begin()
end()= src.end()
At final, object src does not exist
Example:
class D : public B { // assume B has the move constructor
struct timespec m_ts;
char* m_ptr; // pointed to allocated memory
public:
D(D& d, ByMove_t)
: B(d,ByMove), m_ts(d.m_ts), m_ptr(d.m_ptr) {};
};