[Development] RFC: Proposal for a semi-radical change in Qt APIs taking strings

Marc Mutz marc.mutz at kdab.com
Thu Oct 15 09:41:10 CEST 2015


On Thursday 15 October 2015 06:05:34 Thiago Macieira wrote:
> On Thursday 15 October 2015 02:22:50 Marc Mutz wrote:
> > On Thursday 15 October 2015 00:27:14 Thiago Macieira wrote:
> > > Way too much code would break if we did that because we allow people
> > > access
> > > to  the data pointer in QString and to iterate directly
> > > (std::{,w,u16}string don't allow that, which makes parsing them
> > > actually a lot more cumbersome).
> >
> > 
> >
> > Just chiming in to say: It does:
> > http://en.cppreference.com/w/cpp/string/basic_string/data
> 
> Ah, right. The mutable pointer is the one missing...

char *data = &*str.begin();

There might not be explicit API for it, but it's not forbidden to use that 
idiom (if !str.empty(), of course).

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list