I have a question about template template parameters:
We consider the following classes:
Template & lt; Typename t, template & lt; Class, class = std :: allocator & lt; T & gt; & Gt; Class built-in container type = std :: vector & gt; Class MyContainer {Public: T Value1; T value 2; UnderlyingContainerType & LT; T & gt; Container; MyContainer () {} / * Methods implementation goes here;
In this example, a container chat uses an inherent STL-compatible container that does anything stuff.
By allowing the built-in container type to be a template template parameter, instead of the regular template argument, the class allows for the use of MyContainer, such as:
MyContainer & Lt; Int & gt; MCV; // Vector Vector Micrintendent & lt; Int, std :: list & gt; MCL; // No need to write std :: list & lt; Int & gt; // Thanks for the template template parameter
Now, while it will work perfectly with most STL containers, such as std :: vector, std :: deque, std :: list And further, this will not work, for example, with std :: arrays provided in c ++ 11.
The reason for this is that the template parameters from the vector in std :: array are a different signature. Specifically, they are:
std :: vector & lt; Square t, square allocation = std :: allocation & lt; T & gt; & Gt; Std :: array & lt; Square t, int n & gt;
My question is whether the class is a way of making Macintnerer normal, so that the built-in container can also be std :: arrays.
I thank you in advance.
No comments:
Post a Comment