Il 18/07/20 12:08, Arno Rehn ha scritto:
Can't we just hide the QProperty behind a method call, like with an
ordinary getter method? E.g.

class Foo
{
     // ...
     QPropert<int> &bar() {
         Q_D(Foo);
         return d->bar;
     }
};

struct FooPrivate {
     QProperty<int> bar;
};

Sure, property access then isn't as nice as with the struct wrapper,
because you have the method call in between, but at least it's not
undefined behavior and there's a lot less complexity when putting it
into the pimpl object.

I'm assuming that one of the goals is to make the new property syntax invisible and identical for the users. Code like this

  auto value = obj->property();

must still compile, and decltype(value) better be the actual property type and not any proxy object (which are still second class citizens in C++).

My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Attachment: smime.p7s
Description: Firma crittografica S/MIME

_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to