The move assignment operator should often be declared noexcept (i.e. to store the type in STL containers). But the copy-and-swap idiom allows both copy- and move- assignment operators to be defined in a single piece of code. What to do with noexcept specifier in this case? The copy construction can throw, but I doubt whether it can violate the noexcept specifier.
// Is it correct considering that T copy constructor can throw?
T& operator=(T other) noexcept;
noexcept
here is fine. Note that theis_nothrow_*_constructible
traits will still return the correct value because they're implemented similar tonoexcept(declval<T&>() = declval<T const&>())
which also takes into account whether the copy or move constructor throws (because that copy/move needs to happen to pass by value). – Flour