Checking type of parameter pack using enable_if

前端 未结 5 2081
野的像风
野的像风 2021-02-19 21:38

Since there is a restriction on allowed non-type variadic templates, I am trying to write a function taking an arbitrary number of doubles using enable_if. In essen

5条回答
  •  半阙折子戏
    2021-02-19 22:14

    The bool_pack trick again.

    template struct bool_pack;
    template 
    using all_true = std::is_same, bool_pack>;
    

    Then

    template
    using are_all_convertible = all_true::value...>;
    

    and finally

    template::value>::type>
    foo(T... t){ /* code here */}
    

提交回复
热议问题