提问人:LoS 提问时间:5/11/2023 最后编辑:LoS 更新时间:11/5/2023 访问量:684
为什么 std::vector::swap 的 noexcept 规范与所有其他容器交换函数不同?
Why does std::vector::swap have a different noexcept specification than all other container swap functions?
问:
我注意到容器的交换函数具有与所有其他容器不同的 noexcept-specification。具体来说,如果表达式为 true,则函数为 no,但其他容器要求表达式为 true。std::vector
std::allocator_traits<Allocator>::propagate_on_container_swap || std::allocator_traits<Allocator>::is_always_equal
std::allocator_traits<Allocator>::is_always_equal
既然交换函数的行为是相同的,为什么 noexcept-specification 在容器中有所不同?std::vector
答: 暂无答案
评论
std::vector
noexcept
noexcept
noexcept(false)
std::allocator