[Development] User-defined literals for QString (and QByteArray)

Thiago Macieira thiago.macieira at intel.com
Wed Mar 3 20:58:59 CET 2021


On Wednesday, 3 March 2021 07:53:25 PST Andrei Golubev wrote:
> This is the proposal in a nutshell. I'd like to have some feedback and then
> some suggestions regarding:
> 
>   *   Whether we want this for QByteArray as well (similarly to QString it
> allows "from raw data" construction, but then it's not really a string
> class, is it?)

I don't think it's necessary. That doesn't happen often enough and when it 
does, fromRawData is probably enough.

>   *   What suffix to use: in the example above I used "_q", but maybe "_qs"
>   is better or something totally different

I think _qs.

>  *   How to call a namespace: I'd probably go with "QtLiterals" but (looking
>  at [2]) maybe there should be a richer hierarchy? For example,
>  "QtLiterals::StringLiterals", so that the suffix could be reused without
>  conflicts, etc.

No preference.

>   *   Whether *View classes need it (in theory they should allow implicit
>   construction, so probably not)

No, they don't, since you can already construct them without too much typing.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering





More information about the Development mailing list