https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98473
--- Comment #2 from Borislav Stanimirov <b.stanimirov at abv dot bg> --- (In reply to Jonathan Wakely from comment #1) > To meet the requirements of the standard we would need to insert them at the > end and then use std::rotate to reposition them. Or, to save move assignments, first "make a hole" and then copy-construct b's in place (some destructors of moved-out objects) will have to be called. > > I see that libc++ has the same behaviour as libstdc++, which does make me > think the standard is wrong to require this (since it doesn't reflect > reality). I'll have to check the history of the standard. > I reported the same issue there too: https://bugs.llvm.org/show_bug.cgi?id=48619 > > This does compile and work on msvc, so a compile-time check for the > > copy-assignment code is possible. > > No, you can't check that at compile time. It's a dynamic condition. > Presumably MSVC uses std::rotate instead so no check is needed. You definitely can check whether the class has a copy assignment operator and then, based on that, choose either the current implementation or one which doesn't invoke it (rotate or other)