gpt4 book ai didi

c++ - 是否保证 `std::list::splice(std::const_iterator pos, std::list&& other)`保留 `other`为空?

转载 作者:行者123 更新时间:2023-12-02 09:50:22 25 4
gpt4 key购买 nike

std::list::splice(std::const_iterator pos, std::list&& other)是否可以保证other为空?

最佳答案

是的,保证 std::list::splice

(强调我的)

1) Transfers all elements from other into *this. The elements are inserted before the element pointed to by pos. The container other becomes empty after the operation. The behavior is undefined if other refers to the same object as *this.



从标准 [list.ops]/4:

(强调我的)

Effects: Inserts the contents of x before position and x becomes empty. Pointers and references to the moved elements of x now refer to those same elements but as members of *this. Iterators referring to the moved elements will continue to refer to their elements, but they now behave as iterators into *this, not into x.

关于c++ - 是否保证 `std::list::splice(std::const_iterator pos, std::list&& other)`保留 `other`为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60164685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com