Topic: auto-initializing a non-movable non-copyable type
Author: Stephen Kelly <steveire@gmail.com>
Date: Wed, 23 Mar 2016 06:58:01 +0100
Raw View
Hi,
The QObject class is not copyable for several reasons which are core to Qt:
http://doc.qt.io/qt-5/object.html#identity-vs-value
It is also not movable for similar reasons (parent-child relationships,
signal-slot connections and more). Even if issues like that could be
addressed, it would still break any client code which holds a pointer to
the
object.
So, QObject will remain non-copyable and non-movable until very radical
changes in Qt happen, if ever.
That means we can't fully use AAA fully with Qt code because
auto o = QObject{};
won't compile.
Creating QObject-derived instances on the stack is very common for some
types, such as QFile:
http://doc.qt.io/qt-5/qfile.html#reading-files-directly
It should be possible to write
auto file = QFile("in.txt");
despite the QFile type being non-copyable and non-movable.
Are there any existing proposals to allow that, or would such a proposal
have any merit?
Thanks,
Steve.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/56F23069.9030702%40gmail.com.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 23 Mar 2016 08:08:20 +0200
Raw View
On 23 March 2016 at 07:58, Stephen Kelly <steveire@gmail.com> wrote:
> Hi,
>
> The QObject class is not copyable for several reasons which are core to Qt:
>
> http://doc.qt.io/qt-5/object.html#identity-vs-value
>
> It is also not movable for similar reasons (parent-child relationships,
> signal-slot connections and more). Even if issues like that could be
> addressed, it would still break any client code which holds a pointer to
> the
> object.
>
> So, QObject will remain non-copyable and non-movable until very radical
> changes in Qt happen, if ever.
>
> That means we can't fully use AAA fully with Qt code because
>
> auto o = QObject{};
>
> won't compile.
>
> Creating QObject-derived instances on the stack is very common for some
> types, such as QFile:
>
> http://doc.qt.io/qt-5/qfile.html#reading-files-directly
>
> It should be possible to write
>
> auto file = QFile("in.txt");
>
> despite the QFile type being non-copyable and non-movable.
>
> Are there any existing proposals to allow that, or would such a proposal
> have any merit?
See http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0135r0.html.
It has been accepted
by EWG for C++17.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUZim-zvvma%2BqPUZMQQGibDWUp1wCFuUJYWeCf__FXMrCw%40mail.gmail.com.
.
Author: Stephen Kelly <steveire@gmail.com>
Date: Wed, 23 Mar 2016 22:37:21 +0100
Raw View
Ville Voutilainen wrote:
>> Are there any existing proposals to allow that, or would such a proposal
>> have any merit?
>
> See http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/p0135r0.html.
> It has been accepted
> by EWG for C++17.
Great, thanks!
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/56f30c97.03321c0a.66922.638b%40mx.google.com.
.