How to use noexcept in assignment operator with copy-and-swap idiom?
问题 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; 回答1: Since the copy is made on the