[Development] submitting a multi-dimensional container class for Qt: QNDArray

Stephen Kelly stephen.kelly at kdab.com
Fri Dec 28 15:55:00 CET 2012


On Friday, December 28, 2012 08:36:21 Glen Mabey wrote:
> #define Q_DECLARE_METATYPE_2(h1,h2) \
>   QT_BEGIN_NAMESPACE \
>   template <> struct QMetaTypeId< h1,h2 > { \
>       enum { Defined = 1 }; \
>       static int qt_metatype_id() { \
>           static QBasicAtomicInt metatype_id =
> Q_BASIC_ATOMIC_INITIALIZER(0); \ if (!metatype_id.load())
> metatype_id.storeRelease(qRegisterMetaType< h1,h2 >( #h1 "," #h2,
> reinterpret_cast< h1,h2 *>(quintptr(-1)))); \ return
> metatype_id.loadAcquire(); \
>       } \
>   }; \
>   QT_END_NAMESPACE
> 
> This seems like a hack to me, but it works great with all of the compilers
> I've tried it with (32/64-bit g++ on linux and mac; mingw, MSVC 2008,
> 2010). 

> Does anyone foresee a big objection to this approach?

Yes. At least, QNDArray is not part of the typeName() of the metatypes.

For testing, you can probably use this just after the QNDArray definition:

 Q_DECLARE_METATYPE_TEMPLATE_2ARG(QNDArray)

but if this class is going to end up in Qt, then you would need to extend the

 QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F)

macro to deal with it.

Thanks,

-- 
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121228/0db70b35/attachment.sig>


More information about the Development mailing list