Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you write out-of-line constructor with template parameters?

Lets say I have the following struct. How would I write the out-of-line constructor for this?

template <typename T>
struct foo
{
    template <typename Bar>
    foo(int n, Bar bar);
};
like image 281
Chris_F Avatar asked Jun 07 '14 03:06

Chris_F


1 Answers

You would need two separate template declarations:

template <typename T>
template <typename Bar>
foo<T>::foo(int n, Bar bar)
{
    // ...
}
like image 185
David G Avatar answered Nov 09 '22 17:11

David G