Let's say I have a tuple and a function:
typedef std::tuple< std::unqiue_ptr<int>, std::unqiue_ptr<char> > SomeTuple;
void someFunction( std::unqiue_ptr<int>, std::unqiue_ptr<char> );
so in a helper function I am unrolling tuple into arguments:
void unroll( SomeTuple &t )
{
someFunction( std::get<0>( std::move( t ) ), std::get<1>( std::move( t ) ) );
}
It works, but I want to avoid repeating of std::move
multiple times. Naive solutions like:
void unroll( SomeTuple &t )
{
auto &&rt = std::move( t );
someFunction( std::get<0>( rt ), std::get<1>( rt ) );
}
obviosly does not work, as rt is a lvalue
. So is there a way to avoid repeating std::move()
multiple times for each std::get
?
Aucun commentaire:
Enregistrer un commentaire