cv::Ptr assignment operator broken (Bug #3875)


Added by Philipp Hasper over 10 years ago. Updated over 10 years ago.


Status:Cancelled Start date:2014-08-22
Priority:Normal Due date:
Assignee:Roman Donchenko % Done:

0%

Category:-
Target version:3.0-beta
Affected version:branch 'master' (3.0-dev) Operating System:Any
Difficulty: HW Platform:Any
Pull request:

Description

In OpenCV 2.4.x ,
cv::Ptr<Type> a = new Type(something else);
was possible. The new cv::Ptr does not allow this. Maybe this functionality should be included for convenience and a little more backwards compatibility.


Associated revisions

Revision eff302a2
Added by Vadim Pisarevsky almost 10 years ago

Merge pull request #3875 from alalek:fix_build

History

Updated by Roman Donchenko over 10 years ago

First, you're not using the assignment operator in this example. Second, this change was done deliberately to discourage mixing raw and smart pointers.

And as far as convenience goes, I don't think using parentheses instead of an equals sign is any harder.

  • Status changed from New to Cancelled

Updated by Philipp Hasper over 10 years ago

Thanks for the update and many thanks for your work on the smart pointer. Ok, it was not clear to me that mixing raw and smart pointers may be a problem.
Plus, it is not about "harder", its about migration issues.

cv::Ptr<Type> a;
...
a = new Type(...);

is also broken and something you cannot easily migrate to a.reset(new Type(...)) using regular expressions since you have to manually check that a is a cv::Ptr for every replacement. If that was bad coding style anyways and exactly the thing you want to prevent, please tell me so ;-).
Maybe it would be possible to just provide the operator=(T*) which calls .reset() internally.

Also available in: Atom PDF