ublas icon indicating copy to clipboard operation
ublas copied to clipboard

fix(lifetime): extending the lifetime of temporary objects

Open amitsingh19975 opened this issue 2 years ago • 1 comments

The current implementation does not take into account the prvalue that creates an issue while storing it. The prvalue is destroyed after the end of its scope, and if you try to access it, you are entering into the undefined land of C++.

To solve this issue, we employ the trait std::is_lvalue_reference to determine if need to extend the lifetime or not. If an extension is needed, we store the value with the help of universal forwarding. Otherwise, we extend the lifetime using const &.

Resolves #125, resolves #118

amitsingh19975 avatar Feb 09 '22 14:02 amitsingh19975

This Pull request Passed all of clang-tidy tests. :+1:

github-actions[bot] avatar Feb 10 '22 13:02 github-actions[bot]