The noexcept specification for move constructors is noexcept to have performance values ββin C ++ 0x. For example, std::vector<T>::resize , std::vector<T>::reserve can use the T non-throwing constructor if it can be proved that it does not throw. The noexcept is a way to check this property at compile time. If noexcept says that T move-ctor is not throwing, T's objects will be moved, not copied, more likely to achieve better performance.
My question is about exchanging members or exchanging a namespace for a user class T. The C ++ 0x spec takes some effort to export the noexcept specifications std::pair , std::tuple , std::array:swap , possibly indicating that user Certain classes should try to use the same principle. For example, std::pair::swap declared equivalent:
void std::pair::swap(pair& p) noexcept(noexcept(swap(first, p.first)) && noexcept(swap(second, p.second));
It is basically said that the exchange of pairs will depend if either the change of elements is first or second . Swap first , second may have their own noexcept specifications in terms of their members.
Finally, the question is: are there general algorithms (in stl or otherwise) that do different things depending on the noexcept swap specification? Also, are there any implications for this?
source share