Enforce variadic template of certain type

后端 未结 4 1683
执念已碎
执念已碎 2020-12-31 02:35

I would like to enforce the type of variadic template to be identical to an earlier set template type. In the below example, I\'d like T and U to be the same type.

c

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 03:25

    Without implementing of all_same you could also change the constructor code as follows:

    template::value>::type, class... U>
        Foo(F first, U... vals): Foo(vals...) {
        std::cout << "Called multiple argument ctor" << std::endl;
        // [...]   
    }
    

    is_same is the function in an STL

提交回复
热议问题