-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
opencl cv::ocl default class constructors missing noexcept; adds difficulty in later use #19571
Copy link
Copy link
Closed
Labels
Description
Important classes in the cv::ocl namespace like Kernel, Program, Device, etc. are missing the noexcept specifier. This C++11 feature enables easy safe use of such classes when they are default constructed as part of other classes like vector, array, or user-defined classes with member variables. All these classes only set their Impl to zero in their default constructor. I believe adding noexcept is safe and easy. I have a PR ready.
System information (version)
- OpenCV => 4.5.0+
- Operating System / Platform => all
- Compiler => all
Detailed description
class myclass {
cv::ocl::Program myprogram; // can throw, herefore myclass's default constructor can throw, etc...- Currently,
noexceptis missing. When classes likemyclassabove are compiled, the compiler creates default constructors formyclass::myclass()and the compiler-created constructor cascades the lack ofnoexceptupwards sinceProgramis a member var. This cascade limits programmers choices and flexibility in use of default initialization with containers, ownership, member variables, etc. - Declaring them
noexceptaligns these classes with ISO C++ guideline F.6 https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f6-if-your-function-may-not-throw-declare-it-noexcept. - Will also align with a forthcoming PR to add move-semantics to these classes.
- Please note,
noexceptis a C++11 and newer language feature; therefore this is only for the 4.x and newer branches
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
Reactions are currently unavailable