diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index 3f0131da8c..5cdddab35d 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -162,13 +162,13 @@ public: //! default constructor Point_(); Point_(_Tp _x, _Tp _y); - Point_(const Point_& pt); - Point_(Point_&& pt) CV_NOEXCEPT; + Point_(const Point_& pt) = default; + Point_(Point_&& pt) CV_NOEXCEPT = default; Point_(const Size_<_Tp>& sz); Point_(const Vec<_Tp, 2>& v); - Point_& operator = (const Point_& pt); - Point_& operator = (Point_&& pt) CV_NOEXCEPT; + Point_& operator = (const Point_& pt) = default; + Point_& operator = (Point_&& pt) CV_NOEXCEPT = default; //! conversion to another data type template operator Point_<_Tp2>() const; @@ -244,13 +244,13 @@ public: //! default constructor Point3_(); Point3_(_Tp _x, _Tp _y, _Tp _z); - Point3_(const Point3_& pt); - Point3_(Point3_&& pt) CV_NOEXCEPT; + Point3_(const Point3_& pt) = default; + Point3_(Point3_&& pt) CV_NOEXCEPT = default; explicit Point3_(const Point_<_Tp>& pt); Point3_(const Vec<_Tp, 3>& v); - Point3_& operator = (const Point3_& pt); - Point3_& operator = (Point3_&& pt) CV_NOEXCEPT; + Point3_& operator = (const Point3_& pt) = default; + Point3_& operator = (Point3_&& pt) CV_NOEXCEPT = default; //! conversion to another data type template operator Point3_<_Tp2>() const; //! conversion to cv::Vec<> @@ -320,12 +320,12 @@ public: //! default constructor Size_(); Size_(_Tp _width, _Tp _height); - Size_(const Size_& sz); - Size_(Size_&& sz) CV_NOEXCEPT; + Size_(const Size_& sz) = default; + Size_(Size_&& sz) CV_NOEXCEPT = default; Size_(const Point_<_Tp>& pt); - Size_& operator = (const Size_& sz); - Size_& operator = (Size_&& sz) CV_NOEXCEPT; + Size_& operator = (const Size_& sz) = default; + Size_& operator = (Size_&& sz) CV_NOEXCEPT = default; //! the area (width*height) _Tp area() const; //! aspect ratio (width/height) @@ -425,13 +425,13 @@ public: //! default constructor Rect_(); Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height); - Rect_(const Rect_& r); - Rect_(Rect_&& r) CV_NOEXCEPT; + Rect_(const Rect_& r) = default; + Rect_(Rect_&& r) CV_NOEXCEPT = default; Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz); Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2); - Rect_& operator = ( const Rect_& r ); - Rect_& operator = ( Rect_&& r ) CV_NOEXCEPT; + Rect_& operator = (const Rect_& r) = default; + Rect_& operator = (Rect_&& r) CV_NOEXCEPT = default; //! the top-left corner Point_<_Tp> tl() const; //! the bottom-right corner @@ -1164,14 +1164,6 @@ template inline Point_<_Tp>::Point_(_Tp _x, _Tp _y) : x(_x), y(_y) {} -template inline -Point_<_Tp>::Point_(const Point_& pt) - : x(pt.x), y(pt.y) {} - -template inline -Point_<_Tp>::Point_(Point_&& pt) CV_NOEXCEPT - : x(std::move(pt.x)), y(std::move(pt.y)) {} - template inline Point_<_Tp>::Point_(const Size_<_Tp>& sz) : x(sz.width), y(sz.height) {} @@ -1180,20 +1172,6 @@ template inline Point_<_Tp>::Point_(const Vec<_Tp,2>& v) : x(v[0]), y(v[1]) {} -template inline -Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) -{ - x = pt.x; y = pt.y; - return *this; -} - -template inline -Point_<_Tp>& Point_<_Tp>::operator = (Point_&& pt) CV_NOEXCEPT -{ - x = std::move(pt.x); y = std::move(pt.y); - return *this; -} - template template inline Point_<_Tp>::operator Point_<_Tp2>() const { @@ -1431,14 +1409,6 @@ template inline Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) : x(_x), y(_y), z(_z) {} -template inline -Point3_<_Tp>::Point3_(const Point3_& pt) - : x(pt.x), y(pt.y), z(pt.z) {} - -template inline -Point3_<_Tp>::Point3_(Point3_&& pt) CV_NOEXCEPT - : x(std::move(pt.x)), y(std::move(pt.y)), z(std::move(pt.z)) {} - template inline Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) : x(pt.x), y(pt.y), z(_Tp()) {} @@ -1459,20 +1429,6 @@ Point3_<_Tp>::operator Vec<_Tp, 3>() const return Vec<_Tp, 3>(x, y, z); } -template inline -Point3_<_Tp>& Point3_<_Tp>::operator = (const Point3_& pt) -{ - x = pt.x; y = pt.y; z = pt.z; - return *this; -} - -template inline -Point3_<_Tp>& Point3_<_Tp>::operator = (Point3_&& pt) CV_NOEXCEPT -{ - x = std::move(pt.x); y = std::move(pt.y); z = std::move(pt.z); - return *this; -} - template inline _Tp Point3_<_Tp>::dot(const Point3_& pt) const { @@ -1685,14 +1641,6 @@ template inline Size_<_Tp>::Size_(_Tp _width, _Tp _height) : width(_width), height(_height) {} -template inline -Size_<_Tp>::Size_(const Size_& sz) - : width(sz.width), height(sz.height) {} - -template inline -Size_<_Tp>::Size_(Size_&& sz) CV_NOEXCEPT - : width(std::move(sz.width)), height(std::move(sz.height)) {} - template inline Size_<_Tp>::Size_(const Point_<_Tp>& pt) : width(pt.x), height(pt.y) {} @@ -1703,20 +1651,6 @@ Size_<_Tp>::operator Size_<_Tp2>() const return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); } -template inline -Size_<_Tp>& Size_<_Tp>::operator = (const Size_<_Tp>& sz) -{ - width = sz.width; height = sz.height; - return *this; -} - -template inline -Size_<_Tp>& Size_<_Tp>::operator = (Size_<_Tp>&& sz) CV_NOEXCEPT -{ - width = std::move(sz.width); height = std::move(sz.height); - return *this; -} - template inline _Tp Size_<_Tp>::area() const { @@ -1827,14 +1761,6 @@ template inline Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height) : x(_x), y(_y), width(_width), height(_height) {} -template inline -Rect_<_Tp>::Rect_(const Rect_<_Tp>& r) - : x(r.x), y(r.y), width(r.width), height(r.height) {} - -template inline -Rect_<_Tp>::Rect_(Rect_<_Tp>&& r) CV_NOEXCEPT - : x(std::move(r.x)), y(std::move(r.y)), width(std::move(r.width)), height(std::move(r.height)) {} - template inline Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz) : x(org.x), y(org.y), width(sz.width), height(sz.height) {} @@ -1848,26 +1774,6 @@ Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2) height = std::max(pt1.y, pt2.y) - y; } -template inline -Rect_<_Tp>& Rect_<_Tp>::operator = ( const Rect_<_Tp>& r ) -{ - x = r.x; - y = r.y; - width = r.width; - height = r.height; - return *this; -} - -template inline -Rect_<_Tp>& Rect_<_Tp>::operator = ( Rect_<_Tp>&& r ) CV_NOEXCEPT -{ - x = std::move(r.x); - y = std::move(r.y); - width = std::move(r.width); - height = std::move(r.height); - return *this; -} - template inline Point_<_Tp> Rect_<_Tp>::tl() const { diff --git a/modules/core/test/test_misc.cpp b/modules/core/test/test_misc.cpp index 67d0a53995..55615b0d5f 100644 --- a/modules/core/test/test_misc.cpp +++ b/modules/core/test/test_misc.cpp @@ -798,4 +798,27 @@ TEST(Core_Allocation, alignedAllocation) } } + +#if !(defined(__GNUC__) && __GNUC__ < 5) // GCC 4.8 emits: 'is_trivially_copyable' is not a member of 'std' +TEST(Core_Types, trivially_copyable) +{ + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + //EXPECT_TRUE(std::is_trivially_copyable::value); // derived from Vec (Matx) +} + +TEST(Core_Types, trivially_copyable_extra) +{ + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); + EXPECT_TRUE(std::is_trivially_copyable::value); +} +#endif + }} // namespace