[Development] Container refactor update

Peter Kümmel syntheticpp at gmx.net
Wed Jun 20 16:08:38 CEST 2012


On 20.06.2012 13:38, Thiago Macieira wrote:
> On quarta-feira, 20 de junho de 2012 13.09.40, Peter Kümmel wrote:
>> On 20.06.2012 12:31, Thiago Macieira wrote:
>>> On quarta-feira, 20 de junho de 2012 10.47.01, Peter Kümmel wrote:
>>>> When Foo<int>   is used, we would need the meta type information
>>>> with 'int' not with T:
>>>>
>>>> static const char qt_meta_stringdata_Foo<int>[] = {
>>>>
>>>>        "Foo<int>\0\0t\0asignal(int)\0"
>>>>
>>>> };
>>>
>>> Who generates this?
>>
>> moc, we simply tell it for which types it should generate it.
>> This was the idea for "Q_QOBJECT_SPECIALISATION(int)"
>
> Please tell me what it should generate for these classes then:

I see, string based matching signal/slots will not work,
only simple replacements would make sense,
asignal(T t) -> asignal(int t).


But to get different meta types we still can use a specialization:

>
> template<typename T>  class Foo
> {
>      Q_OBJECT
> signals:
>      void asignal(typename std::make_unsigned<T>::type)
>      void othersignal(typename std::remove_reference<T>::type&)
> };

With a typedef c&p is maybe enough:

template<>
class Foo<T>
{
      Q_OBJECT

public:
      typedef int T;

signals:
      void asignal(typename std::make_unsigned<T>::type)
      void othersignal(typename std::remove_reference<T>::type&)
};


static const char qt_meta_stringdata_Foo<int>[] = {
        "Foo<int>\0\0t\0asignal(...)\0"

The signal signature as string isn't relevant than any more.


And not all template "tricks" have to be supported.
Currently Qt says
   "Template classes not supported by Q_OBJECT"
we could switch to something like
   "Template class is too complex to be a QObject"

Peter


>
> template<typename T>  class Foo<T *>
> {
>      Q_OBJECT
> signals:
>      void ptrsignal(T);
> };
>
> template<int Size>  class Bar
> {
>      Q_OBJECT
> signals:
>      void asignal(typename QIntegerForSize<Size>::Unsigned);
> };
>
> Note that I can make this as complex as you can ask.
>
>
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list