How to mimic template variable declaration

前端 未结 3 1714
滥情空心
滥情空心 2021-01-21 16:51

I have a basic type Item which depends on an integer template parameter N and class Data which holds instances of Item

3条回答
  •  情话喂你
    2021-01-21 17:05

    Following may help:

    struct Data
    {
        std::tuple>,
                   std::set>,
                   std::set>,
                   std::set>,
                   std::set>> items;
    
        template 
        bool contains(const Item& x) const {
            static_assert(0 < N && N < 6, "N out of range");
            return std::get(items).find(x) != std::get(items).end();
        }
    };
    

提交回复
热议问题