I noticed that std::flat_set and std::flat_map container adaptors provide some noexcept member functions, in particular there are the followings:
[[nodiscard]] bool empty() const noexcept;
size_type size() const noexcept;
However, all the other container adaptors provide the same member functions as non-noexcept:
[[nodiscard]] bool empty() const;
size_type size() const;
Is there a reason for this difference?
Adding the noexcept specific to a function that is not guaranteed to be non-throwing can be dangerous. This problem occurs precisely with the
std::stack,std::queueandstd::priority_queuecontainer adapters, which provide theempty()andsize()member functions since C++98, and therefore did not force the underlying container's member functions to be non-throwing.