boost::python, returning new PyObject references

David Abrahams david.abrahams at rcn.com
Wed Jan 9 20:49:19 CET 2002


----- Original Message -----
From: "Arnaldur Gylfason" <arnaldur at ru.is>

<<Well. Taking a better look I think so. You're talking about providing an
implicit conversion through a non-explicit templated constructor, right?>>

Yes, just like std::pair, boost::shared_ptr, etc.... IOW, it's an
established idiom.

<<I was so focused on that there should be is-A relationship between them
that I thought that 1 should be a base class of the other. You're not
talking about that.
Am I getting this?>>

Perfectly.


> How many slots are there? N. Now suppose we embed (N+15)/16 = M
compile-time
> constants (e.g. enums) named slots1...slotsM in each capability
template.
> Each one adds a single bit to the constants defined by its Base
parameter.
> Then the assert becomes easy: the templated constructor just checks
for I =
> 1 to M to be sure that (self::slotsI & ~Other::slotsI) == 0.

<<OK. Makes the assert easier in the templated constructor?>>

Yes, at the expense of extensibility. If new slots are added, a user can't
neccessarily extend the capabilities without modifying the library. A
typelist-based approach could allow that.

-Dave





More information about the Cplusplus-sig mailing list