I wonder about two things.
1. Is moving std::tuple
worth implementing? For example for std::tuple<int, int, int>
would we gain anything? Would it be faster than copying or passing by reference?
2. In example given below, is there any real difference between those two?
void print_tuple(const std::tuple<int&&, int&&, int&&> position)
{
int x = std::get<0>(position);
int y = std::get<1>(position);
int z = std::get<2>(position);
std::cout << "x: " << x << " y: " << y << " z: " << z << std::endl;
}
void print_tuple(const std::tuple<int, int, int>&& position)
{
int x = std::get<0>(position);
int y = std::get<1>(position);
int z = std::get<2>(position);
std::cout << "x: " << x << " y: " << y << " z: " << z << std::endl;
}
int main()
{
print_tuple(std::forward_as_tuple(1, 2, 3));
print_tuple(std::move(std::tuple<int, int, int>(4, 5, 6)));
//...
}
Aucun commentaire:
Enregistrer un commentaire