Question

I was wondering if it is possible to write a std::tie()-like function (using template programming) that can bind select components of a tuple only, and bind others to some placeholders like those in std::bind(). If so, one needs only declare variables for the parts he/she is interested in.

For example,

std::tie(x,_1,y,_2) = (2,3,4,5);
Was it helpful?

Solution

Are you looking for std::ignore?

i.e.:

std::tie(x,std::ignore,y,std::ignore) = std::make_tuple(2,3,4,5);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top