The code that lists all the possible permutations until -1 that corrects the problem in your code is:
#include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<std::string> names{
"Julia", "Lucas", "Mia"
};
// sort to make sure we start with the combinaion first in lexicographical order.
std::sort(names.begin(), names.end());
do {
// print what we've got:
for(auto& n : names) std::cout << n << ' ';
std::cout << '\n';
// get the next permutation (or quit):
} while(std::next_permutation(names.begin(), names.end()));
}
Read more about permutations here:
https://brainly.com/question/1216161
#SPJ1