Ich habe die folgende Vorlagenklasse, deklariert in einer .hpp-Datei mit der Implementierung in einer .inl-Datei am Ende der .hpp-Datei enthalten. Sie verfügt über einen Kopiervorlagenkonstruktor, aber ich weiß nicht und kann nirgendwo die korrekte Syntax für die Implementierung des Kopiervorlagenkonstruktors in der .inl-Datei finden. Kennt jemand die korrekte Syntax dafür?
Inhalt von 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
Inhalt von Foo.inl
template <class X>
Foo<X>::Foo(Bar* bar) :
mBar(bar)
{
//some code
}
template <class X>
Foo<X>::someFunction()
{
//do stuff
}