I have a std::vector
of std::typle
:
std::vector<std::tuple<int,int>> vt;
And I can transform the content of the vector to an other vector, by the algorithm std::transform
, like this:
std::vector<int> vi(vt.size());
std::transform( vt.begin(), vt.end(), vi.begin(), [](auto &v) -> int {
return std::get<0>(v);
} );
Of course I could use a function too:
int myget(const std::tuple<int,int>& t)
{
return std::get<0>(t);
}
std::vector<int> vi(vt.size());
std::transform( vt.begin(), vt.end(), vi.begin(), myget );
But would it be possible to use std::get
directly, as a actual parameter in std::transform
?
I mean somthing like this:
std::transform( vt.begin(), vt.end(), vi.begin(), std::get<0, ??? > );