[Development] Qt containers and non-copyable types

Matthew Woehlke mw_triad at users.sourceforge.net
Wed Feb 11 17:52:26 CET 2015

On 2015-02-11 11:39, Thiago Macieira wrote:
> On Wednesday 11 February 2015 11:31:10 Matthew Woehlke wrote:
>> On 2015-02-10 19:44, Thiago Macieira wrote:
>>> ... they aren't useful because we'll never accept movable-but-not-copyable
>>> objects. An implicitly shared container implies a copyable contained
>>> object.
>> Wouldn't you just disable sharing (and indeed, copying the container at
>> all) if the type is non-copyable? (Isn't this what happens with
>> std::vector? I'd have to think yes...)
> That would be required, but the problem is that it can't be easily 
> implemented. Every non-const accessor function has a call to detach(), which 
> requires the copy constructor.

So, it may not count as "easy", but is it not possible to partially
specialize a non-COW implementation for non-copyable types?

> There are a couple of functions that search backwards if you give them 
> negative values. Also because we use signed everywhere and the warnings about 
> comparing signed and unsigned are annoying.

Ah, yes. Okay, then. (TBH I've sometimes found it "nice" that Qt
containers use 'int' and not size_t, so I've probably run into the
conversion thing also and benefited from 'the Qt way'.)


More information about the Development mailing list