I have the following code structure for a template class:
// LagrangeMultiplier.hpp
template <int order>
class LagrangeMultiplier
{
...
};
// LagrangeMultiplier.cpp
#include "LagrangeMultiplier.hpp"
template <int order>
LagrangeMultiplier<order>::LagrangeMultiplier(...)
{
...
}
#include "LagrangeMultiplier.inst"
// LagrangeMultiplier.inst
template class LagrangeMultiplier<6>;
...
template class LagrangeMultiplier<5810>;
That is, I explicitly list the specific template instantiations in a file with a .inst
extension and then include that at the end of my .cpp
file. This is inspired by dealii's handling of templates.
This compiles fine and gives me what I want. However, whenever I try to use this class in another source file, Eclipse tells me that Type 'LagrangeMultiplier<order>' could not be resolved
. This is annoying to me -- is there any way that I can get Eclipse to recognize these specific instantiations of the template class?
Edit: The following is how I would use it in another file:
// lagrange_test.cpp
#include "LagrangeMultiplier.hpp"
int main()
{
constexpr int order = 2702;
LagrangeMultiplier<order> lm();
...
return 0;
}