473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Iterator assignment from a pointer

What exactly can you assign to a set iterator, by assignment or
initialisation? (is this covered in Josuttis? I can't find it).

Some (limited) digging around in the Gnu code shows no operator=, but
2 ctors for iterators, and 3 for const_iterators. For const_iterator,
there's a no-parameter ctor, and a ctor which takes another
const_iterator. The 3rd one is more interesting - it takes a pointer
to a node in the R/B tree, and the iterator itself is actually a
pointer to a node.

This makes me think that there may actually be a way to assign a
pointer to an iterator, with the right runes. If there isn't one, can
anyone tell me why this isn't allowed?

Thanks

Dom
Aug 18 '05 #1
1 1909
Dom Gilligan wrote:
What exactly can you assign to a set iterator, by assignment or
initialisation? (is this covered in Josuttis? I can't find it).
You mean like

set<int>::iterator it;

it = ??? // what is allowed here?

From what I see in the Standard, the iterators for containers are
implementation-defined, and the only requirement on the std::set iterators
is that they are of the bidirectional kind. The only assignment defined
for a bidirectional iterator is from another bidirectional iterator.
Some (limited) digging around in the Gnu code shows no operator=, but
2 ctors for iterators, and 3 for const_iterators. For const_iterator,
there's a no-parameter ctor, and a ctor which takes another
const_iterator. The 3rd one is more interesting - it takes a pointer
to a node in the R/B tree, and the iterator itself is actually a
pointer to a node.
The absence of an explicit operator= suggests that only the compiler-
generated copy assignment can be used. Just like I said, only assignment
from another iterator.
This makes me think that there may actually be a way to assign a
pointer to an iterator, with the right runes. If there isn't one, can
anyone tell me why this isn't allowed?


Assignment from a pointer will yield creation of a temporary iterator
from the pointer and the assignment from that iterator:

set<int>::iterator it;
it = somepointer;

is the same as

set<int>::iterator it;
it = set<int>::iterator(somepointer);

Since set<int>::iterator is implementation-defined, there is nothing
in C++ to say about what constructors it should or should not have.

V
Aug 18 '05 #2

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

Similar topics

38
by: Grant Edwards | last post by:
In an interview at http://acmqueue.com/modules.php?name=Content&pa=showpage&pid=273 Alan Kay said something I really liked, and I think it applies equally well to Python as well as the languages...
6
by: greg | last post by:
Hello all, I havent used STL containers much, as I am used to MFC containers/classes always ..The differences that I could see is iterators and algorithms. The algorithms providing some basic...
11
by: Vivi Orunitia | last post by:
Hi all, I tried looking this up in the sgi docs but it didn't provide any concrete answer to what I'm looking for. Basically, is there any difference between using ::iterator for a container vs...
4
by: steflhermitte | last post by:
Dear cpp-ians, I am working with a structure struct segment { .... vector <meta_segment>::iterator it_Z; .... };
18
by: silversurfer | last post by:
Ok, this should be fairly easy for most of you (at least I hope so), but not for me: Let us say we have got the following elements: std::vector<Entry> models; //Entry is a struct...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
16
by: Juha Nieminen | last post by:
I'm actually not sure about this one: Does the standard guarantee that if there's at least one element in the data container, then "--container.end()" will work and give an iterator to the last...
15
by: vivekian | last post by:
Hi, I have this following class class nodeInfo ; class childInfo { public: int relativeMeshId ;
1
by: David Bilsby | last post by:
All Apologies for cross posing this but I am not sure if this is a VC 8 STL bug or simply an invalid use of the iterator. I have a PCI card access class which basically abstracts a third party...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.