I try to give a function a functor to be more flexible to adjust certain things in my class. Here is some Code:
struct BC {
real operator()(real x, real y, real z) {
return sin(2 * M_PI * x) * sin(2 * M_PI * y) * sin(2 * M_PI * z);
}
};
int main() {
// stuff
subgrid.initBC(BC(), subdomain);
}
and here is the Definition of initBC in a file Subgrid.cpp:
template <class Fun>
void Subgrid::initBC(Fun f, const Subdomain& subdomain) {
f(1, 2, 3); // more or less, just simple usage like that
}
And the declaration, which is inside Subgrid.hpp:
template <class Fun> void initBC(Fun f, const Subdomain & subdomain );
When trying to compile and link it, here is the error message I get
Undefined symbols:
"void Subgrid::initBC<BC>(BC, Subdomain const&)", referenced from:
_main in main.o
ld: symbol(s) not found
I have no clue what is not working here. I think it is probably due to some templating problem, but I can't see what it can possibly be. Any help appreciated, I hope the code snippets are enough, all other code should be irrelevant for this problem I think