I am reviving some old code that was written using C++ 11, but I now want to utilize some C++ 17 features.
auto last = std::unique(creoBomVector.begin(), creoBomVector.end());
creoBomVector.erase(last, creoBomVector.end());
This will compile in C++ 11 no problem, the system knows what type last is.
In C++ 17, the compile error is:
error: 'last' does not name a type error: 'last' was not declared in this scope
In C++ 11, last was not defined in this specific function.
I tried defining 'last', but I quickly realized the compiler was handling 'last' differently than I realized.
I defined last as a string, and I am getting the error: error: 'last' does not name a type.
I admit, my C++ skills are extremely rusty and even at my best, I was mostly using basic standard features to get my scripts done.
Is there a quick fix to the above two lines of code, or do I need to rebuild the way I handled this instruction? I am sure the way I am utilizing the auto keyword in this instance is not recommended.
Aucun commentaire:
Enregistrer un commentaire