Hi there, Commit 5b9006bbdba7dcab01b8e640554a7d7a4b64f76b in qtbase added move capability to QScopedPointer.
That means that in Qt 5.2, if you use C++11, you can do this:
int main(int argc, char **argv)
{
QScopedPointer<int> p_out;
{
QScopedPointer<int> p(new int);
p_out = std::move(p);
}
}
However, if you want to move a QScopedPointer like that, then you don't want a
QScopedPointer at all, but a std::unique_ptr instead.
It also means that you can put a QScopedPointer in your API:
QScopedPointer<int> returnScopedPointer()
{
QScopedPointer<int> p(new int);
return p;
}
int main(int argc, char **argv)
{
QScopedPointer<int> p = returnScopedPointer();
}
Again, this is what std::unique_ptr is for. We should not try to turn
QScopedPointer into an attempt at a NIH std::unique_ptr. Where people have a
need for a std::unique_ptr, they should use it. We should not adapt
QScopedPointer to fit the need instead.
Adding a move contructor to QScopedPointer makes no sense, because moving
means 'escaping the scope', which breaks the fundamental point of
QScopedPointer. QScopedPointer is different to std::unique_ptr and should
remain so.
Please approve:
https://codereview.qt-project.org/#change,64428
Thanks,
--
Join us in October at Qt Developer Days 2013 - https://devdays.kdab.com
Stephen Kelly <[email protected]> | 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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
