Answer the question
In order to leave comments, you need to log in
Is it possible to export templates from dll?
I need to implement the Vector2 class for different types, but I'm too lazy to write the implementation of methods for each manually. It would be reasonable to use templates, but I need to export this class.
Answer the question
In order to leave comments, you need to log in
You can, if you instantiate templates explicitly for predefined types, for example:
template <typename T> struct Vector { ... };
template <typename T> void foo(Vector<T> &); // definition in cpp
template struct Vector<Point2d>;
template struct Vector<Point3d>;
template void foo<Point2d>(Vector<Point2d> &);
template void foo<Point3d>(Vector<Point3d> &);
Vector<Point2d>
and Vector<Point3d>
will be exported.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question