Assume I have a template (called ExampleTemplate) that takes two arguments: a container type (e.g. list, vector) and a contained type (e.g. float, bool, etc). Since containe
I would propose to create adapters.
Your class should be created with the exact level of personalization that is required by the class:
template C, template T>
class Example
{
typedef T Type;
typedef C Container;
};
EDIT: attempting to provide more is nice, but doomed to fail, look at the various expansions:
std::vector
: std::vector>
std::stack
: std::stack>
std::set
: std::set, std::allocator>
The second is an adapter, and so does not take an allocator, and the third does not have the same arity. You need therefore to put the onus on the user.
If a user wishes to use it with a type that does not respect the expressed arity, then the simplest way for him is to provide (locally) an adapter:
template
using Vector = std::vector; // C++0x
Example example;
I am wondering about the use of parameter packs (variadic templates) here... I don't know if declaring C
as template
would do the trick or if the compiler would require a variadic class then.