boost::python, returning new PyObject references

Arnaldur Gylfason arnaldur at ru.is
Wed Jan 9 20:28:34 CET 2002


This is a multi-part message in MIME format.

------_=_NextPart_001_01C19943.D451D1B8
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable



> I'm not sure what you mean by the "type member template". Maybe you
mean the
> nested type "type". Whoops, I realize that I erred. We'd need a
formulation
> that can be used with metafunctions:
>=20
> template <class T, bool checked, class Base>
> index_capability : Base
> {
>     proxy operator[](...
>     ...
> };
>=20
> // this part can be left out until you use mpl
> struct indexable
> {
>     // apply is the analogue to operator()()
>     template <class T, bool checked, class Base>
>     struct apply
>     {
>         // this is its return type
>         typedef index_capability<T,checked,Base>::type type;
>     };
> };
>=20
> Does that answer your question?

Yes. This looks good!

>
>
> > Yes, I was thinking about that but didn't address it. It is handled
> fairly
> > easily with a templated constructor in object<>. You do need to
> > STATIC_ASSERT that the capabilities are a subset. Easy enough using
mpl.

> Do you understand this part, at least abstractly?

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


> How many slots are there? N. Now suppose we embed (N+15)/16 =3D 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 =3D
> 1 to M to be sure that (self::slotsI & ~Other::slotsI) =3D=3D 0.

OK. Makes the assert easier in the templated constructor?

Cheers

Arnaldur



More information about the Cplusplus-sig mailing list