How to specify parameter packs that accept any type or value?

Viewed 304

When specifying the parameter packs for a type, I want to be able to accept not only typenames but also values of arbitrary types. Example:

template <thing... Things>
//        ^^^^^   <- pseudo code
struct Example {};

Example<int,bool>();
Example<4,float,'x'>();

Clearly, thing is not a valid C++ keyword, but is the idea expressed here at all possible?


The context for this is that I have a container adapter that wants to insert its own value type into the container but allow to pass any additional template parameters, and some containers receive not just type arguments but also values (std::array would be a popular example).

template <template <typename...> typename Container, typename... Args>
struct Adapter {
  struct Node { /* ... */ };
  Container<Node,Args...> container;
};

Adapter<std::vector>(); // fine
Adapter<std::vector,MyAllocator>(); // fine
Adapter<std::array,3>(); // nope because 3 is not a typename
0 Answers
Related