[Development] QList
Marc Mutz
marc.mutz at kdab.com
Sun Mar 19 02:09:17 CET 2017
On Saturday 18 March 2017 23:17:54 Ville Voutilainen wrote:
> On 19 March 2017 at 00:13, Marc Mutz <marc.mutz at kdab.com> wrote:
> >> > port these code lines manually come Qt 6. I do not consider auto
> >> > variables "generic code".
> >>
> >> Right. I, however, do consider them generic code. :)
> >
> > You're free to call a chicken a pig for your own entertainment, but in
> > the interest of understanding what everyone says, please stick to
> > established definitions. Generic code is generally understood to be code
> > that uses generic
>
> I have no trouble finding Concepts designers who consider auto the most
> generic concept, one that has no requirements. It fits right into a
> spectrum of constraints
> between a concrete type and, well, itself, as auto is the other end of
> that spectrum;
> that's especially true of auto-type parameters, which are already in C++14,
> but also of auto-type variables, which are already in C++11. Considering
> that you can use an auto-type variable as a result of an overloaded call,
> I daresay it fulfills the definition of generic code even by the measures
> you cited.
Yes, auto can be called the most generic concept. Yes, using auto arguments
makes a function generic. No, using auto to simply save having to write the
type of the initialising expression in code that cannot be called generic in
its original form does _not_ make said code generic. And that is what we were
talking about:
On Saturday 18 March 2017 11:25:12 Ville Voutilainen wrote:
> On 18 March 2017 at 11:51, Marc Mutz <marc.mutz at kdab.com> wrote:
> > 1. Replace QList in generic code by QListOrVector, tell users to hold
> > QLists
> >
> > they get from Qt API only in type-deduced variables.
>
> In other words, introduce generic code where there wasn't generic code
> before - users writing
> non-generic code calling non-templates that return QLists will need to
> use deduction or a metaprogramming tool.
Ok, I can see where there might be a misunderstanding here. The comma in my
original sentence should be read as a semicolon. I meant:
1a. Replace QList in generic code by QListOrVector
1b. Tell users to hold QLists they get from Qt API only in type-deduced
variables.
With (1b), I was referring to stuff like:
QStringList parts = string.split(...); // Don't do that in new code
auto parts = string.split(...); // do this instead
--
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, C++ and OpenGL Experts
More information about the Development
mailing list