0

I found the following statement in the book C++ Template: The complete Guide:

Template template parameters for function templates are not allowed.

But he following piece of code compiles and run for me.

template< typename T, template <typename elem,typename = std::allocator<elem> > class Cont>
void disp(const Cont<T>& t)
{
    for(auto it = t.cbegin(); it != t.cend(); ++it)
    {
        cout<<"Value : "<<*it<<endl;
    }
}

int main()
{
    int arr[] = {1,2,3,4,5};
    std::vector<int> vec(arr, (arr+ sizeof(arr)/sizeof(arr[0])));
    disp(vec);
}

Does this mean that the new C++ standard supports template template parameters for function? The answer for the following post says otherwise: How to get template template argument deduction working with functions?

Community
  • 1
  • 1
sajas
  • 1,599
  • 1
  • 17
  • 39
  • 1
    I'm somewhat confused with the question. Are you asking if the language standard supports something (template template params in this case) that you're toolchain clearly *does* support? Or is it the contrast to the book your reading that is the main issue you're pondering? What is the revision/year of book? (and yes, template-templates are allowed as params, even variadic ones, [See an alternative live](http://ideone.com/J9iqjm) ). – WhozCraig Jan 02 '14 at 05:29
  • 3
    `Cont` is a class, whereas `template void Func(T);` is a function, the other question states that `Func` cannot be a template parameter. `Cont` can. – Jarod42 Jan 02 '14 at 05:31
  • @Jarod42 Thanks. I get it now.I confused it with having template template srguments for template functions. Thanks for the reply – sajas Jan 02 '14 at 05:37
  • @WhozCraig I got confused with the statement in the book. I get it now. Thanks. – sajas Jan 02 '14 at 05:42

0 Answers0