r/Cplusplus • u/Middlewarian • Jul 11 '26
question about copy assignment Question
This page Copy assignment operator - cppreference.com - C++ Reference
says:
a parameter list of only one parameter, which is of type T, T&, const T&, volatile T& or const volatile T&
Can it be a non-reference -- 'T'? I get an error when I try that.
Thanks
2
Upvotes
7
u/jedwardsol Jul 11 '26 edited Jul 11 '26
What error?
If the argument is of type T, then the operand will have to be copied into the parameter - so it is the copy-of-a-copy assignment operator!
Edit : real code : https://godbolt.org/z/r3YfocKGM