Type: User Story
Priority: P3: Somewhat important
Affects Version/s: None
Fix Version/s: None
Component/s: Core: QString and Unicode
There are two use-cases for a type-erased QStringBuilder-expression container:
- Build up a larger expression step-by-step
- Passing expressions into and out of functions, esp. across ABI boundaries
Regarding the first point: Within a single function, provided QTBUG-99291 is implemented, I can just use auto variables to store sub-expressions:
But, and this ties in with the second point, if I want to factor parts of the building into a separate function, I'd need to make it a template, with all the associated disadvantage (executable code bloat, excessive compiler error messages). With a type-erased expression container, I could write a normal function:
and this function could even be out-of-line.
This expression container would also be able to support appending:
With auto variables, this is not possible, because op+= changes the static type of the variable. But because QStringBuilderExpression is type-erased, it can store both the old and the new type in the same object.