www.digitalmars.com         C & C++   DMDScript  

c++ - linker error 42 when using member function pointers of template classes

reply Shinomori <aoshi gmx.net> writes:
see attached file, a more detailed description is included in the comments.

For short; the linker outputs error 42 (undefined symbol)
when using member function pointers of template classes.
Identical code works for non-templates.
Jul 15 2011
parent Shinomori <aoshi gmx.net> writes:
I have done some more experiments and it
looks like a problem with the instanciation
of the member functions in templates.

When using:

func_ptr_type ptr = &function_name;

everything is fine, but with

func_ptr_type ptr[] = { &function_name };

it is not; function_name does not get instanciated
if not used otherwise.

So it is propably a compiler problem which causes
template functions not beeing instanciated when
their pointers are used inside arrays/structs only.
The functions are included when directly accessed,
however, using their pointer in e.g. an array should
also count as access, so my vague guess is an error
in the compiler.
Jul 16 2011