Are the move semantics used in Example A necessary, and which struct is superior?
Example A:
struct A
{
std::string a;
A( std::string a ) : a( std::move(a) ){ }
};
Example B:
struct B
{
std::string b;
B( const std::string& b ) : b( b ){ }
};
I don't believe this is a duplicate question. I am asking specifically which example is superior from the perspective of using member initialization in a class constructor. None of the examples or answers listed in the other question dealt with member initialization.
I don't like that the constructor is called with a reference parameter, then copied into the member. It seems that it could be wasteful to have multiple copy operations.
I want to "pipe" the data into the members as efficiently as possible but I don't want to take rvalues as the constructor parameters.