Is it legal to destruct and construct the elements of a vector externally? Assuming that you leave the same set of elements in a constructed state that you started with, of course? And assuming to don't do anything obviously dumb, like calling the destructor twice on the same element, or similar.
Leaving exceptions aside, I'm envisioning something like the following:
int main ()
{
std::vector<std::string> v (10, "Hello");
v [2].std::string::~string ();
new (&v [2]) std::string ("World");
}
Or would something like this be UB? What about the other standard containers?