Sunday 15 February 2015

c++11 - C++ unordered_map exception safety -


I was wandering C ++ specifications (cplusplus.com) and found that nothing about the exception security for std :: unordered_map has been reported

If I originally write

  map ["foo"] = 5;   

And the exception is thrown because I have been excluded from memory or bad_lok, what can I think about my map?

  • Is this a legitimate state? (Basic guarantee)
  • Is it left unchanged? (Strong guarantee)
  • Is it left in latent position? (No guarantee)

    23.2.4.1 Exception guarantees security [associative. Reqmts.except]

    2 An exception is inserted from any operation in an insert or emplace function, so there is no relation to the inclusion to insert a single element.

    This paragraph index applies to the operator. Therefore:

    • It has been left unchanged. (Strong guarantee)

No comments:

Post a Comment