<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 20, 2021, at 14:12, Christopher Di Bella <<a href="mailto:cjdb.ns@gmail.com" class="">cjdb.ns@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">I've noticed that our sequence containers' noexcept specifiers for swap aren't to spec. Is this intentional, or some gross oversight?</div><div class=""><br class=""></div><div class="">Example from <vector></div><div class=""><span style="font-family:monospace" class=""><br class=""></span></div><div class=""><span style="font-family:monospace" class="">    void swap(vector&)<br class="">#if _LIBCPP_STD_VER >= 14<br class="">        _NOEXCEPT;<br class="">#else<br class="">        _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||<br class="">                    __is_nothrow_swappable<allocator_type>::value);<br class="">#endif</span></div><div class=""><br class=""></div><div class="">To me, this looks like it's saying that swap is unconditionally noexcept in C++17 and C++20, and possibly the opposite of [vector.capacity]/12 otherwise?<br class=""></div><div class=""><br class=""></div><div class=""><a href="http://eel.is/c++draft/vector#capacity-12" class="">[vector.capacity]/12</a> notes:</div><div class=""><br class=""></div><div class=""><span style="font-family:monospace" class="">constexpr void swap(vector& x)<br class="">  noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||<br class="">           allocator_traits<Allocator>::is_always_equal::value);</span></div><div class=""><br class=""></div><div class="">If this is an oversight, I'll file a bug and patch ASAP. If it's intentional, is it explicitly documented somewhere to explain the deviation? This was a surprise when writing tests for <span style="font-family:monospace" class="">std::ranges::swap</span>'s noexcept status.<br class=""></div></div></div></blockquote><div><br class=""></div><div><div>Based on <a href="https://en.cppreference.com/w/cpp/container/vector/swap" class="">https://en.cppreference.com/w/cpp/container/vector/swap</a>, it seems to me like what we want here is:</div><div><br class=""></div><div>    void swap(vector&)</div><div>    #if _LIBCPP_STD_VER < 17</div><div>        _NOEXCEPT</div><div>    #else</div><div>        _NOEXCEPT_((std::allocator_traits<Allocator>::propagate_on_container_swap::value ||</div><div>                    std::allocator_traits<Allocator>::is_always_equal::value))</div><div>    #endif</div><div><br class=""></div><div>In other words, mark it as unconditionally noexcept (as a conforming extension) pre-C++17, and implement the noexcept specification per the spec in C++17 and above. Do you agree? If so, I think it would be great to submit a patch and add tests for all the places where this is broken. I would be verrrrry grateful if you were willing to do that, I’ll review it.</div><div><br class=""></div><div>Louis</div><div class=""><br class=""></div></div></div></body></html>