Skip to content

Types in core/types.hpp should be trivially copyable. #20718

@gottagofaster236

Description

@gottagofaster236
System information (version)
  • OpenCV => 4.5.3
Detailed description

Take, for example, cv::Point_.
There are user provided copy and move constructors, copy assignment and move assignment operators defined:

Point_(const Point_& pt);
Point_(Point_&& pt) CV_NOEXCEPT;

Point_& operator = (const Point_& pt);
Point_& operator = (Point_&& pt) CV_NOEXCEPT;

Because of that, the type is not trivially copyable. For example, that means you can't use std::memcopy or std::atomic with the type.

The fix for that would be to remove those constructors and operators altogether, since the compiler would generate the identical implicitly-defined ones.

Steps to reproduce
#include <opencv2/core/types.hpp>
#include <type_traits>
#include <iostream>

int main() {
    std::cout << std::is_trivially_copyable_v<cv::Point>;  // => 0
}
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions