Скажи, что у меня есть версия const t & :
void yetAnotherFunc( const T &input ) {
// do something...
}
void myFunc( const T &input ) {
yetAnotherFunc( input );
}
int main()
{
myFunc( someT() ); // pass in a rvalue
return 0;
}
Эффективно ли он такого же, как и T && с std :: forward ниже с точки зрения копии. Какие есть различия? < /p>
void yetAnotherFunc( T &&input ) {
// do something...
}
void myFunc( T &&input ) {
yetAnotherFunc( std::forward( input ) );
}
int main()
{
myFunc( someT() ); // pass in a rvalue
return 0;
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... rgument-wh
Мобильная версия