C++11 features (#778)

* Make noncopyable constructor and destructor default

C++11 provides the functionality.
Defining empty functions cause all classes derived from noncopyable
to be non-trivially constructible and non-trivially destructible.

For example, matrix with compile-time layout by definition does not
require an explicit destructor and should be trivially destructible
; however, deriving from noncopyable makes it non-trivially
destrutible. This also affects vector<T, 2> and vector<T, 3>.

* Delete array2d copy constructor and assignment operators
This commit is contained in:
Deniz Evrenci 2017-08-25 18:40:22 +09:00 committed by Davis E. King
parent ef25c56fbb
commit 6fbe3c6055
3 changed files with 8 additions and 12 deletions

View File

@ -160,6 +160,9 @@ namespace dlib
set_size(rows,cols);
}
array2d(const array2d&) = delete; // copy constructor
array2d& operator=(const array2d&) = delete; // assignment operator
#ifdef DLIB_HAS_RVALUE_REFERENCES
array2d(array2d&& item) : array2d()
{
@ -330,10 +333,6 @@ namespace dlib
T* last;
mutable bool at_start_;
// restricted functions
array2d(array2d&); // copy constructor
array2d& operator=(array2d&); // assignment operator
};
// ----------------------------------------------------------------------------------------

View File

@ -122,6 +122,9 @@ namespace dlib
- std::bad_alloc
!*/
array2d(const array2d&) = delete; // copy constructor
array2d& operator=(const array2d&) = delete; // assignment operator
array2d(
array2d&& item
);
@ -252,12 +255,6 @@ namespace dlib
An example of such an object is the dlib::cv_image.
!*/
private:
// restricted functions
array2d(array2d&); // copy constructor
array2d& operator=(array2d&); // assignment operator
};
template <

View File

@ -19,8 +19,8 @@ namespace dlib
!*/
protected:
noncopyable() {}
~noncopyable() {}
noncopyable() = default;
~noncopyable() = default;
private: // emphasize the following members are private
noncopyable(const noncopyable&);
const noncopyable& operator=(const noncopyable&);