[C++-sig] Re: Tutorial - Techniques

David Abrahams dave at boost-consulting.com
Sun May 18 16:19:00 CEST 2003


Nicodemus <nicodemus at globalite.com.br> writes:

>>Did you actually test your MetaInjector thing?  I'm pretty sure you
>>need to derive the metaclass from the metaclass used for Boost.Python
>>objects, or you'll get a metaclass conflict.
>>
>
> Silly me! I did test, but with a pure Python class! 8P
>
> Indeed, trying to inject methods in a Boost.Python class gives an
> error: "TypeError: metatype conflict among bases". So I tried to use
> your MetaInjector, but it gives the same error. Any idea?

Err, did you take my code literally, and write:

    # The one Boost.Python uses for all wrapped classes.
    class BoostPythonMetaclass(type): pass

??

That doesn't work, of course.  The "one true metaclass" already exists
in Boost.Python.  You need to get the metaclass, either by explicitly
making it available in an extension module, or by getting it from some
wrapped class:

     BoostPythonMetaclass = some_wrapped_class.__class__

>>About reducing compilation time: this section is very closely related
>>to http://www.boost.org/libs/python/doc/v2/faq.html#c1204.  Should we
>>cross-link them somehow?
>>
>
> I added a blurb to the end of that section pointing to the FAQ.

I think you ought to add some entries to the FAQ which point into the
techniques paper as well... e.g., "Compilation takes forever! How can
I make it faster?"

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list