Hi, I have a question from " Live Interactive Session : 3 " on 13/04/23 and Prof. Partha Pratim Das asked me to Post this in Discussion forum and remind TA's to get it answered from him properly using codes.
While deciding code
semantics for move operation in Module 50, we face challenge of deciding parameter type for std::move
(M50.19)
One solution to this is overloading std::move giving two definitions one for moving lvalue and one for moving rvalue argument. But still perfect forwarding problem remains !! M(50.20)
Later in Module 51 we see for Perfect forwarding by a template function we use std::forward component which checks reference type from template deduction and forwards arguments to their corresponding parameters correctly. Resolves the problem ! M(51.14)
BUT std::forward C++ implementation is itself overloaded for lvalue reference and for rvalue reference.( M51.27 )
So how is overloading std::forward for set of n arguments cheaper than overloading std::move while perfect forwarding?