G-API: Use object instead of reference in extended lifetime case#14946
Merged
alalek merged 2 commits intoopencv:masterfrom Jul 2, 2019
Merged
G-API: Use object instead of reference in extended lifetime case#14946alalek merged 2 commits intoopencv:masterfrom
alalek merged 2 commits intoopencv:masterfrom
Conversation
Member
Author
|
@dmatveev please review |
Contributor
|
It still could be (and must be)
|
Member
Author
|
@dmatveev totally makes sense to add |
Member
Author
|
@alalek please merge! |
AhiyaHiya
added a commit
to AhiyaHiya/opencv
that referenced
this pull request
Jul 7, 2019
* master: (74 commits) Merge pull request opencv#14917 from rgarnov:gapi_planar_kernels Fixed initUndistortRectifyMap AVX2 implementation Merge pull request opencv#14959 from dvd42:onnx_clip videoio: eliminate build warnings (clang) ts: runtime check for misused 'optional' test data files 3rdparty(itt): support AARCH64 tensroflow support maxpoolgrad Fix blob detector insertion sort Fix crash, add assert and test Merge pull request opencv#14946 from andrey-golubev:obj_not_ref re-enable CPU_BASELINE=FP16 on Armv7 platform Merge pull request opencv#14828 from armenpoghosov:parmen_RANSACPointSetRegistrator_getSubset_disaster_cleanup Merge pull request opencv#14916 from terfendail:wsignmask_deprecated core: evaluate CV_Error() parameters during static scans dnn: fix build with Vulkan Merge pull request opencv#14936 from StefanBruens:crosscorr_cleanup Explicitly default operator= for Vec<T, n> Fix JS sample of dnn 3rdparty: TBB version 2018u1 => 2019u8 cmake: support rpath-link linker option ...
a-sajjad72
pushed a commit
to a-sajjad72/opencv
that referenced
this pull request
Mar 30, 2023
G-API: Use object instead of reference in extended lifetime case (opencv#14946) * Use object instead of reference * Make the object const
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pullrequest changes
const lvalue reference to object since in the given expression a new object is returned from a function.
Original code is a valid behavior since this is the case for extended lifetime of the temporary object (const lvalue reference of the same type is bound to that temporary).
Anyway, the code is doubtful and requires the developer to check for the return type and provide some rationale to ensure the code is correct. Taking this into account, it's easier to replace reference with an object.
References: Temporary Object Lifetime - look at the exceptions from the rules