How can instantiate this template struct?
template<typename T,
template<typename, template <typename> class D= std::allocator
>class Z=std::vector
>
struct amen
{
Z<T,D<T> > cc; // i know D template class parameter is not visible , how do i do it?
};
int main(){
amen<int> moreAmen;
}
Can anyone show me how to do it?
You have this wrong. It should be
The allocator of
std::vectoris not a template. Then the declaration ofccbecomesAs you gave a default argument for the allocator, you don’t need to pass any argument for it. If you wanted to, you would need to pass
std::allocator<T>or some other allocator againThe default argument of a parameter of a template template argument is not “inherited” to the corresponding template template parameter of your class/struct template. You need to specify it again, like above (by stating
std::allocator<U>as default template argument).