0

I have this class definition in .h file:

class PolygonPath
{
  public:
    template<class T> explicit PolygonPath(const Polygon<T> &);
    template<class T> Polygon<T> toPolygon() const;
}

In .cpp file, I define my methods. Then, I would like to define explicit template for Polygon<float> and Polygon<long>. So, I define them like that:

template class PolygonPath::PolygonPath<float>(const Polygon<float> &); //Fail
template class Polygon<float> PolygonPath::toPolygon<float>() const; //Ok
template class PolygonPath::PolygonPath<long>(const Polygon<long> &); //Fail
template class Polygon<long> PolygonPath::toPolygon<long>() const; //Ok

For constructor, I'm not able to define an explicit template specialization. I have this error at compilation: "error: ‘PolygonPath’ is not a class template". I also try with this syntax:

template <> PolygonPath::PolygonPath(const Polygon<float> &)

It compiles but I get another error at link: "undefined reference to `urchin::PolygonPath::PolygonPath(urchin::Polygon const&)'".

NathanOliver
  • 171,901
  • 28
  • 288
  • 402
Saelhenen
  • 163
  • 1
  • 9

1 Answers1

4

Remove class from your constructor's explicit instantiation.

template PolygonPath::PolygonPath<long>(const Polygon<long> &);

and

template Polygon<long> PolygonPath::toPolygon<long>() const;

MujjinGun
  • 480
  • 3
  • 9