473,499 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on vector of vector iterators

I am trying to iterate through a vector of vector iterators and it's
failing at compile time on gcc 3.4.3. As far as I can tell it's
correct -- but the compiler isn't liking it obviously.

Here's a set of test statements that I tested it against besides my
original vector< myobj >:
-------------------------------------------------
typedef vector<int> IntVector;
typedef vector<int>::iterator IntVectorIterator;
typedef vector<IntVectorIterator> IntVectorIteratorVector;
typedef vector<IntVectorIteratorVector>::iterator
IntVectorIteratorVectorIterator;

IntVectorIteratorVector iviv;
IntVectorIteratorVectorIterator iviv_iter = iviv.begin();
-------------------------------------------------

The compiler gave:
-----------------------------------
error: conversion from
`__gnu_cxx::__normal_iterator<IntVectorIterator*,
std::vector<IntVectorIterator, std::allocator<IntVectorIterator> > >'
to non-scalar type
`__gnu_cxx::__normal_iterator<IntVectorIteratorVec tor*,
std::vector<IntVectorIteratorVector,
std::allocator<IntVectorIteratorVector> > >' requested
-----------------------------------
on the line that had the begin().

It looks like it's trying to set the iterator to one level deeper. Is
there a way for this to work?

Dec 15 '05 #1
3 2133
David Crawford <cr************@gmail.com> wrote:
I am trying to iterate through a vector of vector iterators and it's
failing at compile time on gcc 3.4.3. As far as I can tell it's
correct -- but the compiler isn't liking it obviously.

Here's a set of test statements that I tested it against besides my
original vector< myobj >:
-------------------------------------------------
typedef vector<int> IntVector;
typedef vector<int>::iterator IntVectorIterator;
typedef vector<IntVectorIterator> IntVectorIteratorVector;
typedef vector<IntVectorIteratorVector>::iterator
IntVectorIteratorVectorIterator;
Did you mean

typedef vector<IntVectorIterator>::iterator
IntVectorIteratorVectorIterator;

?

IntVectorIteratorVector iviv;
IntVectorIteratorVectorIterator iviv_iter = iviv.begin();
-------------------------------------------------

The compiler gave:
-----------------------------------
error: conversion from
`__gnu_cxx::__normal_iterator<IntVectorIterator*,
std::vector<IntVectorIterator, std::allocator<IntVectorIterator> > >'
to non-scalar type
`__gnu_cxx::__normal_iterator<IntVectorIteratorVec tor*,
std::vector<IntVectorIteratorVector,
std::allocator<IntVectorIteratorVector> > >' requested
-----------------------------------
on the line that had the begin().

It looks like it's trying to set the iterator to one level deeper. Is
there a way for this to work?


--
Marcus Kwok
Dec 15 '05 #2
Yep. Just been looking at it for too long I guess.

Now have it as
typedef IntVectorIteratorVector::iterator
IntVectorIteratorVectorIterator;

Dec 15 '05 #3

David Crawford wrote:
I am trying to iterate through a vector of vector iterators and it's
failing at compile time on gcc 3.4.3. As far as I can tell it's
correct -- but the compiler isn't liking it obviously.

Here's a set of test statements that I tested it against besides my
original vector< myobj >:
-------------------------------------------------
typedef vector<int> IntVector;
typedef vector<int>::iterator IntVectorIterator;
typedef vector<IntVectorIterator> IntVectorIteratorVector;
typedef vector<IntVectorIteratorVector>::iterator
IntVectorIteratorVectorIterator;
You seem to be typedef'ing for the sake of typedef'ing here. Similar in
concept to

const int one_hundred = 100; // Look, ma! No magic numbers in my code.

typedef std::vector<grocery> ShoppingList has the potential to clarify
your code.

typedef vector<int> IntVector just rearranges the characters a bit and,
as you saw, leaves you just as confused.

Gavin Deane

IntVectorIteratorVector iviv;
IntVectorIteratorVectorIterator iviv_iter = iviv.begin();
-------------------------------------------------

The compiler gave:
-----------------------------------
error: conversion from
`__gnu_cxx::__normal_iterator<IntVectorIterator*,
std::vector<IntVectorIterator, std::allocator<IntVectorIterator> > >'
to non-scalar type
`__gnu_cxx::__normal_iterator<IntVectorIteratorVec tor*,
std::vector<IntVectorIteratorVector,
std::allocator<IntVectorIteratorVector> > >' requested
-----------------------------------
on the line that had the begin().

It looks like it's trying to set the iterator to one level deeper. Is
there a way for this to work?


Dec 16 '05 #4

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

Similar topics

11
2880
by: Richard Thompson | last post by:
I've got a memory overwrite problem, and it looks as if a vector has been moved, even though I haven't inserted or deleted any elements in it. Is this possible? In other words, are there any...
3
1222
by: deancoo | last post by:
If I have a container, say a vector, with 5 elements, and I initialize iterator variables to point to the beginning and end of the container, are those iterators going to always be valid if I...
3
2898
by: codefixer | last post by:
Hello, I am trying to understand if ITERATORS are tied to CONTAINERS. I know the difference between 5 different or 6(Trivial, on SGI). But what I fail to understand is how can I declare all 5...
13
20108
by: zaineb | last post by:
Hi, This is a follow-up of sort of this thread:...
0
1386
by: subramanian100in | last post by:
Suppose I have vector<intc; for (int i = 0; i < 10; ++i) c.push_back(i); vector<int>::iterator it = find(c.begin(), c.end(), 5); If I do, c.insert(c.begin(), 10);
0
7131
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,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6894
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
7388
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
5470
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,...
1
4919
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...
0
3099
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...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
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...

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.