People tend to say pass by (const) reference if you want speed
, to be honest I rarely use const reference on methods I create just because of speed, I only make a reference when I need it, for example to give a value to a variable, as in this SSCE
void Do( int& iref )
{
a = 2;
}
{
int a = 0;
Do( a );
}
The question actually is, if the object was created on the function call, if will it also be passed as a reference, how does that works?
void Add( CString& strPath )
{
g_Path.push_back( strPath );
}
for( std::string line; getline( input, line ); )
{
Add( CString( line.c_str() ) ); //object created on function call
}