I have the following templated class, declared in an .hpp file with the implementation in a .inl file included at the end of the .hpp file. It has a templated copy constructor, but I don't know nor can't find anywhere the correct syntax for implementing the templated copy constructor in the .inl file. Does anyone know the correct syntax for this?
Contents of 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
Contents of Foo.inl
template <class X>
Foo<X>::Foo(Bar* bar) :
mBar(bar)
{
//some code
}
template <class X>
Foo<X>::someFunction()
{
//do stuff
}