c++c++11std-tie

Is it to possible to extend std::tie in c++11 to accept place holders?


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);

Solution

  • Are you looking for std::ignore?

    i.e.:

    std::tie(x,std::ignore,y,std::ignore) = std::make_tuple(2,3,4,5);