[SUGGESTION] Already constructed object getting constructed again as we pass it as out parameter ? why ? #736
Unanswered
jituderaps
asked this question in
Q&A
Replies: 1 comment
-
That's like suggesting to ban |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
AFAIK, the motive of out parameter is to accept an object(i.e. not constructed yet) and construct it, but what if we pass an already constructed object as out argument, it will get constructed / assigned again and that is inefficient.
for example :
demo of similar problem to understand the construction of object: https://cpp2.godbolt.org/z/zhYo997ad
Expected result : compilation error
Actual result/error : running fine
Beta Was this translation helpful? Give feedback.
All reactions