[PyQt] %MappedType with non-class template arg?

Phil Thompson phil at riverbankcomputing.com
Fri Sep 10 09:21:08 BST 2010


On Fri, 10 Sep 2010 09:47:20 +0200, Hans Meine
<meine at informatik.uni-hamburg.de> wrote:
> Hi Phil,
> 
> Am Donnerstag 09 September 2010, 16:35:00 schrieb Phil Thompson:
>> <meine at informatik.uni-hamburg.de> wrote:
>> > I was happy when I saw that %MappedType supports templates, but then
I
>> > realized that I could not use it for my multi-dimensional array type
>> > [1]
>> > since
>> > it does not support non-class arguments (integer dimension in my
case).
>> > 
>> > Would that be hard to fix?
>> 
>> It does support non-class arguments.
> 
> That sounds great, but...
> 
>> > [1] http://tinyurl.com/NumpyArray is what I am dealing with
>> 
>> I don't see the problem with this. Compare with PyQt's QPair<TYPE, int>
>> where TYPE is a class.
> 
> I am not sure I see the connection.  QPair does take two types, one of
> them 
> being int here.  Maybe "non-class argument" was a little bit misleading,
I
> was 
> thinking of
> 
>   template<class value_type> ...
> 
> which is a synonym (don't we all love ambiguity) for
> 
>   template<typename value_type>
> 
> in contrast to
> 
>   template<unsigned int DIMENSION> class FixedSizeVector ...
> 
> Of course, 'int' is a 'class' (/'typename') in the above template-arg
> sense 
> and is supported by SIP, but I am interested in this exact use case:
> 
>   typedef NumpyArray<4, vigra::UInt16> UInt16Array4D;

So the template arguments are constant, so don't even bother with a
template in sip. Just do...

%MappedType UInt16Array4D
{
...
};

Phil


More information about the PyQt mailing list