dimanche 10 septembre 2017

Curly braces as part of the initialization inside a for-loop in C++ [duplicate]

This question already has an answer here:

In some C++ function, I just saw this:

for (uint i{start}; i < end; ++i)
{
    ...
}

The variables start and end are of type uint. My question would be about those first two curly braces around start.

I suspect those to be a list initialization, but I never saw it in a for-loop before, so I wonder what the advantages (or maybe disadvantages) of this approach would be.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire