Re: C++11 features, move semantics?



On Wed, 2015-01-21 at 12:09 +0000, Chris Vine wrote:
On Wed, 21 Jan 2015 08:39:46 +0100
Murray Cumming <murrayc murrayc com> wrote:
On Sun, 2014-12-28 at 15:42 +0100, Christof Meerwald wrote:
Hi,

just wondering if anyone has given any thought on C++11 features for
gtkmm.

One thing that seems very unfortunate is that all objects are
non-movable (due to them being explicitly made non-copyable which
then also deletes the move constructor).
[snip]

I believe it's possible to make classes movable but not copyable. That
feels strange to me, but maybe that's just because I'm not using C++11
day to day. I hope that this wouldn't lead to code that looked too
much like the widgets were being copied. I can imagine a lot of
confusion from less experienced coders.

It is possible (the canonical example is of course std::unique_ptr) and
it does not confuse, because lvalues can only be moved by converting
them to rvalues, in other words by calling std::move on them.  Calling
std::move makes it clear, I think, that no copying is involved.

Does anyone see any need for this in gtkmm?

In theory, I guess we could make Gtk::Widget movable but not copyable,
so we could do things like this sometimes:

Gtk::Widget widget = generate_some_widget();

But I think that would be very confusing.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]