#include <vector>
std::vector<int> f()
{
return std::vector<int>(1024);
}
void use_1(std::vector<int> const&)
{}
void use_2(std::vector<int> const&)
{}
int main()
{
{
auto const& v = f(); // style 1
use_1(v);
use_2(v);
}
{
auto&& v = f(); // style 2
use_1(v);
use_2(v);
}
{
auto v = f(); // style 3
use_1(v);
use_2(v);
}
}
Which is better? style 1, style 2, or style 3?
Aucun commentaire:
Enregistrer un commentaire