Hi all,

I've been using Boost.Python to expose some instances of a class
template to a python module.  I ran into a problem with my class's
method templates not being instantiated, leading to "undefined symbol"
on import.  Actually, this message from back in 2004 describes the
problem exactly:

http://mail.python.org/pipermail/cplusplus-sig/2004-February/006586.html

The advise is to move the method definitions into the header file, but
I have some methods I want to ensure are not inlined, so I ended up
using explicit template instantiations instead.  Kind of a pain.

The standard has this to say about function template instantiations:

14.7.1 Implicit instantiation
2. Unless a function template specialization has been explicitly
instantiated or explicitly specialized, the function template
specialization is implicitly instantiated when the specialization is
referenced in a context that requires a function definition to exist.

So my question is, why isn't taking the address of some instance of a
templatized function and passing it to def() enough to require the
function definition to exist?  Should this be considered a usability
bug in the library, a problem with my compiler, or maybe neither?

I'm using gcc 4.4.

Thanks,
Kyle Cronan
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to