Restrict variadic template arguments
问题 Can we restrict variadic template arguments to a certain type? I.e., achieve something like this (not real C++ of course): struct X {}; auto foo(X... args) Here my intention is to have a function which accepts a variable number of X parameters. The closest we have is this: template <class... Args> auto foo(Args... args) but this accepts any type of parameter. 回答1: Yes it is possible. First of all you need to decide if you want to accept only the type, or if you want to accept a implicitly