[Development] Qt containers and non-copyable types (was: Why can't QString use UTF-8 internally?)

Matthew Woehlke mw_triad at users.sourceforge.net
Wed Feb 11 17:31:10 CET 2015


On 2015-02-10 19:44, Thiago Macieira wrote:
> On Tuesday 10 February 2015 19:07:09 Matthew Woehlke wrote:
>> Heh. That reminds me, when will Qt classes get emplace methods?
> 
> I added those methods to my local refactor of QVector, but..
> 
>> Or the ability to accept movable-but-not-copyable types?
> 
> ... 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...)

>> (Something else to consider for Qt 6 would be fixing the index types to
>> be size_t instead of int. Assuming we don't just drop the classes.)
> 
> For QVector, we might have to switch to qint64 or to qintptr or some other 
> name for a *signed* integer type.

If it has to be signed, ssize_t (okay, same as qintptr I guess, so
really I'm just voting against an always-64-bit type) would seem
preferable. (Why does it need to be signed? For methods that return 'not
found' I'd expect the all-1's value, a la std::string. Where do you
actually need a negative *value*, e.g. -N, not just -1?)

-- 
Matthew




More information about the Development mailing list