During the linking stage, I kept getting "undefined reference to 'Foo::k_funky'".
So then I tried declaring the functor's constructor and operator function constexpr:
Alas, aggregate initialization seems not to have worked. The same error pops up.
The functor type is actually passed as a template parameter (could that be why I get this problem?).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
struct functor{
constexprshortoperator()(char c)const{return c-'0';}
};
template <class Converter_Type>
class Foo{
public:
using converter_t = Converter_Type;
private:
staticconstexpr converter_t k_convert {};
};
//I use a separate file for defining member functions of Foo<Converter_Type>,
// and those functions use the functor. However, I #include that file right
// after the class definition.
If you would like, I can post a link to my code, but it's pretty messy and clumped (I plan on making it more legible once I'm 100% sure everything works).
> The functor type is actually passed as a template parameter
> (could that be why I get this problem?).
No. To pin-point the source of the error one would have to see the code.
But the cause of the error is easy to identify:
somewhere, (in the code that is not posted), the address of the object is being taken.
(Perhaps not directly; the code contains a construct that requires the address of the object).
For the address to be taken, the static member must be defined, and that has not been done.