[C++-sig] wrapping typedef equivalent types

Neal Becker ndbecker2 at gmail.com
Wed Oct 19 17:59:22 CEST 2005

David Abrahams wrote:

> Neal Becker <ndbecker2 at gmail.com> writes:
>> What happens if, using boost::python, I try to wrap 2 type equivalent
>> classes?
>> For example (this is a trivial example):
>> class_<int>...
>> class_<int32_t>...
>> where int == int32_t
>> My real objective is to wrap classes
>> template<int_t> class X {};
>> where int_t is
>> int (natural int size)
>> int32_t (force 32-bit)
>> int64_t (force 64-bit)
>> Can wrapped X<int>, X<int32_t>, X<int64_t> co-exist in the same python
>> module?
> No, all wrapped classes have to have different types.  You could add a
> dummy parameter to X in order to distinguish them.

I don't understand the dummy parameter suggestion.  Could you elaborate?

I found a different solution.  I just expose the int32_t and int64_t
versions, then use python code to set the equivalence.  In python, I write 
something like:

if (intsize() == 4): X = X32

I guess there's nothing wrong with that approach :)

More information about the Cplusplus-sig mailing list