I find it very hard to meet the exception guarantees for flat_meow
(take flat_set
for example below).
https://eel.is/c++draft/flat.set#overview-2:
flat_set meets the requirements of an associative container ([associative.reqmts]), except that: ...
According to this, flat_set
should meet the exception guarantees specified in
https://eel.is/c++draft/containers#associative.reqmts.except:
erase(k) does not throw an exception unless that exception is thrown by the container's Compare object (if any)
if an exception is thrown by any operation from within an insert or emplace function inserting a single element, the insertion has no effect.
flat_set
relies on its underlying containers to do insert
and erase
. So, the above requirements also imply:
A. The container should not throw on erase(iter)
.
~ However, this is not true for deque
and vector
:
https://eel.is/c++draft/containers#deque.modifiers-5:
Throws: Nothing unless an exception is thrown by the assignment operator of T.
https://eel.is/c++draft/containers#vector.modifiers-4:
Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator of T.
B. The container should provide strong guarantee for insert(iter,single-element)
.
~ However, for example, this is not required by deque
. The wordings doesn't specify the effects when not inserting at beginning or end.
https://eel.is/c++draft/containers#deque.modifiers-3:
If an exception is thrown while inserting a single element at either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T, the effects are unspecified.
I think the standard should give explicit specifications for exception guarantees for flat_meow::insert/erase
. What's more, this is also related to flat_meow
's invariant guarantee against exceptions. As different containers provides different level of exception guarantee, what should flat_meow
behave when an exception of unknown effect occurs in insert/erase
functions?
https://eel.is/c++draft/flat.set#overview-6:
If any member function in [flat.set.defn] exits via an exception, the invariant is restored.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4