C
catphive.lists
I have a bunch of function object classes of the form
struct MyFunc : unary_function<arg,ret>
{
MyFunc(arg) : state(arg) {}
void operator() (arg) { /*code here*/ }
};
in various cpp files. Now, the problem is that I happen to write two of
these with the same name in different modules that don't know anything
about each other, I will get a linker error, because the linker won't
be sure of what constructor to link against. How do I protect against
this?
I can't just mark a struct static, as that would only be indicating
that an instance of the struct (if specified) is static *data* and
*not* that the struct itself constructor and member functions itself
has module level linkage only. Is there an actual good way to handle
this?
struct MyFunc : unary_function<arg,ret>
{
MyFunc(arg) : state(arg) {}
void operator() (arg) { /*code here*/ }
};
in various cpp files. Now, the problem is that I happen to write two of
these with the same name in different modules that don't know anything
about each other, I will get a linker error, because the linker won't
be sure of what constructor to link against. How do I protect against
this?
I can't just mark a struct static, as that would only be indicating
that an instance of the struct (if specified) is static *data* and
*not* that the struct itself constructor and member functions itself
has module level linkage only. Is there an actual good way to handle
this?