Why is a vector considered nothrow_move_constructible?

Vector move constructor specification (copied outside the standard):

vector(vector&&); 

Note 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 (ie, 1):

 #include<vector> #include<iostream> int main() { std::cout << std::is_nothrow_move_constructible<std::vector<int>>::value << '\n'; } 

What is the reason for this apparent discrepancy?

+6
source share
1 answer

The standard allows the implementation to strengthen the specification of a method exception according to

17.6.5.12 Limitations on Exception Handling [res.on.exception.handling]

4 Destructor operations defined in the C ++ standard library should not throw exceptions. Each destructor in the C ++ standard library should behave as if it had an exception specification to exclude metadata. Any other functions defined in the C ++ standard library that do not have an exception specification may raise exceptions defined during implementation, unless otherwise specified. 191 An implementation can enhance this implicit exception specification by adding an explicit one. 192

+6
source

Source: https://habr.com/ru/post/958100/


All Articles