@ -6116,11 +6114,11 @@ These operations do not throw.
template<typenameT>
class Vector2 {
// ...
public:
Vector2(Vector2&& a) { *this = a; } // just use the copy
Vector2& operator=(Vector2&& a) { *this = a; } // just use the copy
// ...
public:
private:
T* elem;
int sz;
};
@ -6356,7 +6354,6 @@ A `swap` can be handy for implementing a number of idioms, from smoothly moving
##### Example, good
class Foo {
// ...
public:
void swap(Foo& rhs) noexcept
{
@ -9094,20 +9091,20 @@ The `unique_ptr` protects against leaks by guaranteeing the deletion of its obje
template<typenameT>
class X {
// ...
public:
T* p; // bad: it is unclear whether p is owning or not
T* q; // bad: it is unclear whether q is owning or not
// ...
};
We can fix that problem by making ownership explicit:
template<typenameT>
class X2 {
// ...
public:
owner<T*> p; // OK: p is owning
T* q; // OK: q is not owning
// ...
};
##### Exception
@ -17454,7 +17451,6 @@ Flag uses where an explicitly specialized type exactly matches the types of the
##### Example
class X {
// ...
public:
explicit X(int);
X(const X&); // copy
@ -21749,7 +21745,6 @@ If you define a move constructor, you must also define a move assignment operato
##### Example
class X {
// ...
public:
X(const X&) { /* stuff */ }
@ -21758,6 +21753,8 @@ If you define a move constructor, you must also define a move assignment operato
X(x&&) noexcept { /* stuff */ }
// BAD: failed to also define a move assignment operator
// ...
};
X x1;
@ -21841,10 +21838,10 @@ Prevent leaks. Leaks can lead to performance degradation, mysterious error, syst
template<classT>
class Vector {
// ...
private:
T* elem; // sz elements on the free store, owned by the class object
int sz;
// ...
};
This class is a resource handle. It manages the lifetime of the `T`s. To do so, `Vector` must define or delete [the set of special operations](???) (constructors, a destructor, etc.).