The specification for vector's move constructor is (copied out of the standard):
vector(vector&&);
Notice the lack of noexcept
. But both gcc 4.8 and Clang 3.2 report that std::is_nothrow_move_constructible<std::vector<int>>::value
returns true (i.e, 1):
#include<vector>
#include<iostream>
int main()
{
std::cout << std::is_nothrow_move_constructible<std::vector<int>>::value << '\n';
}
What is the cause of this apparent discrepancy?
The standard allows an implementation to strengthen the exception specification of a method as per
17.6.5.12 Restrictions on exception handling [res.on.exception.handling]
4 Destructor operations defined in the C++ standard library shall not throw exceptions. Every destructor in the C++ standard library shall behave as if it had a non-throwing exception specification. Any other functions defined in the C++ standard library that do not have an exception-specification may throw implementation-defined exceptions unless otherwise specified.191 An implementation may strengthen this implicit exception-specification by adding an explicit one.192
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With