对Loki::Tuple的扩展EasyTuple(附Tupleoperator实现)

来源:互联网 发布:超级基因优化液无错 编辑:程序博客网 时间:2024/06/11 07:40
Tupleoperator的实现也主要用FieldHelper来实现,借用了Loki::TL::IterateTypes的思想
template <int LastLength, class H, template <class> class Operator>
struct TupleOperator
{
    typedef Loki::TL::Length<typename H::TList> lengh;
    typedef Loki::FieldHelper<H,lengh::value-LastLength> head_helper;
    typedef    typename head_helper::ResultType head_t;
    typedef TupleOperator<LastLength-1,H, Operator> tail_t;
    tail_t tail;
    
    void operator()(H& obj)
    {
        Operator<head_t> op;
        op(head_helper::Do(obj));
        tail.operator()(obj);
    }
};

template <class H, template <class> class Operator>
struct TupleOperator<0,H,Operator>
{
    void operator()(H& obj){}
};

原创粉丝点击