How can I make this variadic template code shorter using features from C++14 and C++1z?

前端 未结 4 1682
[愿得一人]
[愿得一人] 2020-12-11 02:55

This is a code snippet that I am going to use in order to check whether the variadic template types are unique:

template 
struct is_one_of         


        
4条回答
  •  执笔经年
    2020-12-11 03:25

    #include 
    
    template 
    constexpr bool is_one_of = (std::is_same{} || ...);
    
    template 
    constexpr bool is_unique = true;
    
    template 
    constexpr bool is_unique = is_unique && !is_one_of;
    

    DEMO

提交回复
热议问题