Whether you actually call "free" doesn't matter. You're falling victim to the "smart pointers/modern C++ is memory safe" fallacy. It is not, for reasons I've elaborated on at length numerous times before.
std::vector<std::string> v;
v.push_back("Hello");
for (auto&& s: v) {
v.clear();
std::cout << s; // use after free in modern C++
}
There is no reasonable way for a compiler to precisely check for use after free in C++ short of changing the language, and this can be easily proven.In any case, a std::vector<shared_ptr<std::string> > would actually avoid the issue in this particular case.
Use after free... is more about use of raw pointers IMO. I wouldn't describe that code to be a "use after free" at all. In most languages, you are simply not allowed to change the container at all. Iterator invalidation is a hard issue in any language.
shared_ptr is also not memory safe when combined with references, which you need to use to call methods on the shared_ptr'd object or to pass those objects to most functions.