[C++-sig] Re: std::complex<double>?

Raoul Gough RaoulGough at yahoo.co.uk
Fri Jan 9 16:03:22 CET 2004


David Abrahams <dave at boost-consulting.com> writes:

> "Neal D. Becker" <nbecker at hns.com> writes:
[snip]
>> z=CDoubleVec(2)
>>>>> z
>> <hello.CDoubleVec object at 0x8446a54>
>>>>> z[0]
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>> TypeError: No Python class registered for C++ class std::complex<double>
>
> That's because the vector_indexing_suite is trying to treat
> std::complex like any other class, instead of like an int (i.e. a
> type with an immutable Python counterpart).  I don't know what the
> answer to that is, though.  Joel/Raoul?
>
>> I also will need std::complex<int>.  What would I need for this?
>
> complex<int> isn't even guaranteed to work by the C++ standard.  You'd
> need to explicitly register to/from-python converters for it.

I think what Jonathan Brandmeyer was suggesting would do the
trick. The indexing suite(s) just assume that the contained type is
already known to Python, and the easiest way to do that is to create a
boost::python::class_ instance for it.

-- 
Raoul Gough.
export LESS='-X'





More information about the Cplusplus-sig mailing list