Skip to content

Could cv::Mat be nothrow movable? #25065

@Quuxplusone

Description

@Quuxplusone

Describe the feature and motivation

A Folly user has noticed that Mat(Mat&&) is noexcept(false). This means that it gets the "vector pessimization" with std::vector (making copies on reallocation rather than moving), and it can't be put into a folly::fbvector<cv::Mat> at all (facebook/folly#1821), because Folly actually asserts at compile time that moving can be done without throwing exceptions.

Looking at the code, I don't see any obvious reason Mat(Mat&&) couldn't just be replaced with Mat(Mat&&) CV_NOEXCEPT. But there might be a subtle reason? If so, it would be great to document that reason with a code comment on the declaration and/or definition of the throwing move constructor, so that people don't ask this question again. :)

Additional context

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions