get part of std::tuple

前端 未结 7 1228
没有蜡笔的小新
没有蜡笔的小新 2020-12-02 23:09

I have a tuple of unknown size (it\'s template parametr of method)

Is it way to get part of it (I need throw away first element of it)

For example, I have

7条回答
  •  天涯浪人
    2020-12-03 00:07

    With C++17, you can use std::apply:

    template 
    std::tuple tuple_tail(const std::tuple& t)
    {
        return apply([](auto head, auto... tail) {
            return std::make_tuple(tail...)};
        }, t);
    }
    

提交回复
热议问题