How do I strip a tuple<> back into a variadic template list of types?

后端 未结 5 2325
死守一世寂寞
死守一世寂寞 2020-12-15 07:29

Is there a way to strip a std::tuple in order to get it back to T...?

Example

Suppose

5条回答
  •  有刺的猬
    2020-12-15 08:11

    You can not directly "return" a parameter pack, so what you need is something like this:

    template< typename... Ts >
    struct vct
    { ... };
    
    template< typename T >
    struct make_vct;
    
    template< typename... Ts >
    struct make_vct< std::tuple< Ts... > >
    {
        typedef vct< Ts... > type;
    };
    

    and use

    using Y = make_vct< U >::type;
    

提交回复
热议问题