#include <iostream>
#include <tuple>
template <typename T, typename Tuple>
auto push_front(const T& t, const Tuple& tuple)
{
return std::tuple_cat(std::make_tuple(t), tuple);
}
template <typename Tuple, std::size_t ... Is>
auto pop_front_impl(const Tuple& tuple, std::index_sequence<Is...>)
{
return std::make_tuple(std::get<1 + Is>(tuple)...);
}
template <typename Tuple>
auto pop_front(const Tuple& tuple)
{
return pop_front_impl(tuple,
std::make_index_sequence<std::tuple_size<Tuple>::value - 1>());
}
int main()
{
std::tuple<char> tc{'*'};
std::tuple<int, char> tic = push_front(42, tc);
std::tuple<char> tc2 = pop_front(tic);
std::cout << (tc == tc2) << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHVwbGU+Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgVCwgdHlwZW5hbWUgVHVwbGU+CmF1dG8gcHVzaF9mcm9udChjb25zdCBUJiB0LCBjb25zdCBUdXBsZSYgdHVwbGUpCnsKICAgIHJldHVybiBzdGQ6OnR1cGxlX2NhdChzdGQ6Om1ha2VfdHVwbGUodCksIHR1cGxlKTsKfQoKdGVtcGxhdGUgPHR5cGVuYW1lIFR1cGxlLCBzdGQ6OnNpemVfdCAuLi4gSXM+CmF1dG8gcG9wX2Zyb250X2ltcGwoY29uc3QgVHVwbGUmIHR1cGxlLCBzdGQ6OmluZGV4X3NlcXVlbmNlPElzLi4uPikKewogICAgcmV0dXJuIHN0ZDo6bWFrZV90dXBsZShzdGQ6OmdldDwxICsgSXM+KHR1cGxlKS4uLik7Cn0KCnRlbXBsYXRlIDx0eXBlbmFtZSBUdXBsZT4KYXV0byBwb3BfZnJvbnQoY29uc3QgVHVwbGUmIHR1cGxlKQp7CiAgICByZXR1cm4gcG9wX2Zyb250X2ltcGwodHVwbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjptYWtlX2luZGV4X3NlcXVlbmNlPHN0ZDo6dHVwbGVfc2l6ZTxUdXBsZT46OnZhbHVlIC0gMT4oKSk7Cn0KCmludCBtYWluKCkKewogICAgc3RkOjp0dXBsZTxjaGFyPiB0Y3snKid9OwogICAgCiAgICBzdGQ6OnR1cGxlPGludCwgY2hhcj4gdGljID0gcHVzaF9mcm9udCg0MiwgdGMpOwogICAgc3RkOjp0dXBsZTxjaGFyPiB0YzIgPSBwb3BfZnJvbnQodGljKTsKICAgIHN0ZDo6Y291dCA8PCAodGMgPT0gdGMyKSA8PCBzdGQ6OmVuZGw7Cn0K