473,791 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

std::list<>::sp lice invalidation of iterators

The C++ standard says in 23.2.2.4 "list operations" that the
various forms of splice invalidate iterators and references to
the spliced elements. This makes the splice operation a lot less
useful than it otherwise could be. It seems unnecessary to
invalidate these iterators and references, and I am puzzled why
the standard says that it happens. Furthermore, the "merge"
operation that also moves elements from one list to another does
not have any note saying that it invalidates any iterators or
references.

Can anyone enlighten me?

--
"While the Melissa license is a bit unclear, Melissa aggressively
encourages free distribution of its source code."
--Kevin Dalley <ke***@seti.org >
Jan 31 '08 #1
2 2960
Ben Pfaff wrote:
The C++ standard says in 23.2.2.4 "list operations" that the
various forms of splice invalidate iterators and references to
the spliced elements. This makes the splice operation a lot less
useful than it otherwise could be. It seems unnecessary to
invalidate these iterators and references, and I am puzzled why
the standard says that it happens.
No reason. The working paper n2461 indicates that the next standard will
change those provisions.
Furthermore, the "merge"
operation that also moves elements from one list to another does
not have any note saying that it invalidates any iterators or
references.

Can anyone enlighten me?

Best

Kai-Uwe Bux

Feb 1 '08 #2
jk********@gmx. net writes:
Ben Pfaff wrote:
>The C++ standard says in 23.2.2.4 "list operations" that the
various forms of splice invalidate iterators and references to
the spliced elements. This makes the splice operation a lot less
useful than it otherwise could be. It seems unnecessary to
invalidate these iterators and references, and I am puzzled why
the standard says that it happens.

No reason. The working paper n2461 indicates that the next standard will
change those provisions.
Thanks so much for pointing that out. The provisions of n2461
look great.
--
Ben Pfaff
http://benpfaff.org
Feb 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3128
by: Dave | last post by:
Hello all, I'm pondering why the default underlying container for std::priority_queue<> is std::vector<>. It would seem that inserts are liable to happen anywhere, which would make std::list<> a superior alternative. Why factors am I not considering here? Why in the general case would std::vector<> be best? Thanks, Dave
14
5634
by: Dave | last post by:
Hello all, After perusing the Standard, I believe it is true to say that once you insert an element into a std::list<>, its location in memory never changes. This makes a std::list<> ideal for storing vertices of an arbitrary n-ary tree where a vertex contain pointers to its parent / children. These parent / child vertices need to stay put if we've got pointers to them somewhere! Am I correct in my assertion?
6
6663
by: PengYu.UT | last post by:
Hi, Suppose I have a list which contains pointers. I want the pointer got by dereferencing the iterator be a pointer pointing to a const object. But std::list<const T*>::const_iterator doens't give me this capability. So I want std::list<T*>::iterator. However, the container is of type std::list<T*>. How to get std::list<const T*>::iterator?
2
2696
by: Christoph Heindl | last post by:
Hi, I'm currently struggling with a design decision. One of my classes (named Attributable) has a protected member of type std::list<StrongReference<Attribute> > Basically the list has strong references that point to Attribute's. In Attributable i want to provide an stl like interface for bidirectional iterators like:
3
2133
by: janzon | last post by:
Hi! Sorry for the bad subject line... Here's what I mean. Suppose we deal with C++ standard integers lists (the type is indifferent). We have a function f, declared as list<intf(int); Now we have an integer list p, say. For each element x in p, we want to repace x with f(x) to get a new, possibly larger, integer list. Note
10
2708
by: barcaroller | last post by:
I'm writing a real-time application which is currently using C++ linked lists. The items have to be sorted. I collect the items as they come in, search the list sequentially until I find the insertion point, and insert the item. This is proving to be inefficient. Is there a more efficient alternative (maybe in Boost or standard C)?
7
1948
by: barcaroller | last post by:
Does a list<Tkeep track of its size or is the size re-calculated every time you call list<T>.size()?
3
1495
by: subramanian100in | last post by:
There are some operations like sort, remove, remove_if which are available as list<Tmember functions; but vector<T>, deque<Tdo not seem have those functions. If am correct in this, what is the reason for that. Moreover sort, remove, remove_if are available in <algorithmalso. Then why does list<Thave these member operations ? Kindly clarify. Thanks V.Subramanian
17
4196
by: Isliguezze | last post by:
Does anybody know how to make a wrapper for that iterator? Here's my wrapper class for std::list: template <class Tclass List { private: std::list<T*lst; public: List() { lst = new std::list<T>(); } List(const List<T&rhs) { lst = new std::list<T>(*rhs.lst); } List(int n, const T& value) { lst = new std::list<T>(n, value); }
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.