У меня есть следующий шаблонный класс, объявленный в файле .hpp с реализацией в файле .inl, включенном в конец файла .hpp.
Он имеет конструктор шаблонного копирования, но я не знаю и не могу найти где-нибудь правильный синтаксис для реализации конструктора шаблонного копирования в файле .inl. Кто-нибудь знает правильный синтаксис для этого?
Содержимое Foo.hpp
template <class X>
class Foo
{
public:
explicit Foo(Bar* bar);
//I would like to move the definition of this copy ctor to the .inl file
template <class Y> explicit Foo(Foo<Y> const& other) :
mBar(other.mBar)
{
assert(dynamic_cast<X>(mBar->someObject()) != NULL);
//some more code
}
void someFunction() const;
private:
Bar* mBar;
}
#include Foo.inl
Содержимое Foo.inl
template <class X>
Foo<X>::Foo(Bar* bar) :
mBar(bar)
{
//some code
}
template <class X>
Foo<X>::someFunction()
{
//do stuff
}