473,804 Members | 5,054 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

deque iterator problem with const

I'm implementing a SAX handler with libxml++. I have this piece of code:

void PalamedeParser: :on_start_eleme nt(const std::string &name, const
AttributeList &attributes) {
AttributeList:: iterator it = attributes.begi n();

with AttributeList defined as
typedef std::deque< Attribute > xmlpp::SaxParse r::AttributeLis t

On the initialization of the iterator, I got this error:

conversion from
`__gnu_norm::_D eque_iterator<x mlpp::SaxParser ::Attribute, const
xmlpp::SaxParse r::Attribute&, const xmlpp::SaxParse r::Attribute*>' to
non-scalar type `__gnu_norm::_D eque_iterator<x mlpp::SaxParser ::Attribute,
xmlpp::SaxParse r::Attribute&, xmlpp::SaxParse r::Attribute*>' requested

It seems the compiler does not like the fact that attributes is a
constant. How should I iterate this deque?

Frederik
--
Running Mandrake Linux 10.0 Cooker

Jul 22 '05 #1
2 1630

"Frederik Himpe" <se*@reply.to.i nvalid> wrote in message
news:pa******** *************** ***@reply.to.in valid...
I'm implementing a SAX handler with libxml++. I have this piece of code:

void PalamedeParser: :on_start_eleme nt(const std::string &name, const
AttributeList &attributes) {
AttributeList:: iterator it = attributes.begi n();

with AttributeList defined as
typedef std::deque< Attribute > xmlpp::SaxParse r::AttributeLis t

On the initialization of the iterator, I got this error:

conversion from
`__gnu_norm::_D eque_iterator<x mlpp::SaxParser ::Attribute, const
xmlpp::SaxParse r::Attribute&, const xmlpp::SaxParse r::Attribute*>' to
non-scalar type `__gnu_norm::_D eque_iterator<x mlpp::SaxParser ::Attribute,
xmlpp::SaxParse r::Attribute&, xmlpp::SaxParse r::Attribute*>' requested

It seems the compiler does not like the fact that attributes is a
constant. How should I iterate this deque?


Use a const iterator.

AttributeList:: const_iterator it = attributes.begi n();

john
Jul 22 '05 #2
On Tue, 27 Apr 2004 14:06:26 +0100, John Harrison wrote:

"Frederik Himpe" <se*@reply.to.i nvalid> wrote in message
news:pa******** *************** ***@reply.to.in valid...
I'm implementing a SAX handler with libxml++. I have this piece of code:

void PalamedeParser: :on_start_eleme nt(const std::string &name, const
AttributeList &attributes) {
AttributeList:: iterator it = attributes.begi n();

with AttributeList defined as
typedef std::deque< Attribute > xmlpp::SaxParse r::AttributeLis t

On the initialization of the iterator, I got this error:

conversion from
`__gnu_norm::_D eque_iterator<x mlpp::SaxParser ::Attribute, const
xmlpp::SaxParse r::Attribute&, const xmlpp::SaxParse r::Attribute*>' to
non-scalar type
`__gnu_norm::_D eque_iterator<x mlpp::SaxParser ::Attribute,
xmlpp::SaxParse r::Attribute&, xmlpp::SaxParse r::Attribute*>' requested

It seems the compiler does not like the fact that attributes is a
constant. How should I iterate this deque?


Use a const iterator.

AttributeList:: const_iterator it = attributes.begi n();


Hmm, of course. This works fine. I should really practice my C++ more, in
order not to forget such obvious things over time.

Thank you for the quick answer!
Frederik
--
Running Mandrake Linux 10.0 Cooker

Jul 22 '05 #3

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

Similar topics

19
4381
by: chris | last post by:
Hello, I've recently been trying to understand the various structures supplied by c++, and the one I find most confusing is deque. One quick question about this. It seems most implementations of deque are quite complex. Why couldn't I implement deque with a couple of vectors V,W where the deque is the element of V in reverse order followed by W? This would appear to me to satisfy all the conditions, and be significantly simpler. Am I...
3
2291
by: Travis L Spencer | last post by:
Hey, I am trying to insert a bunch of Token objects into a collection called tokens of type deque<Token>. The problem is that the output of Tokens::print is just junk. For instance, the call at the end of main produces this output: Value: fsdf Width: 0
5
6159
by: yancheng.cheok | last post by:
after reading http://www.codeproject.com/vcpp/stl/vector_vs_deque.asp, i realize that deque has its own speed advantage over vector in all the aspect (except for memory deallocation). does it mean that we should prefer deque over vector? (in contrast with c++ standard, which recommence vector over deque) thanks!
0
2682
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 looked for one on the net (I did browse the boost library though). It doesn't matter right now, anyway. To put it simply, Abstract Iterator is mainly a wrapper class. It helps
8
2968
by: Gernot Frisch | last post by:
std::deque<intd; d.push_front(13); int* p13 = &d.begin(); d.push_front(1); d.push_back(2); Can I be safe, that p13 points to 13? I mean, unless I erase the 13, of course.
15
3538
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and you want to make a deque which can contain any objects of any of those types. Normally what you would have to do is to make a deque or vector of pointers of the base class type and then allocate each object dynamically with 'new' and store the...
12
2653
by: arnuld | last post by:
It works fine. any advice on making it better or if I can improve my C++ coding skills: /* C++ Primer - 4/e * * Chapter 9 - Sequential Containers * exercise 9.18 - STATEMENT * Write a program to copy elements from a list of "ints" * to 2 "deques". The list elements that are even should go into one deque * and even elements should go into 2nd deque.
1
2936
by: Donos | last post by:
Hello I have the following declaration in my code, ****************************************************************** struct mHandleObj { HANDLE h; };
2
2416
by: subramanian100in | last post by:
In ISO/IEC 14882:2003 document, in the section '23.2.1.3 deque modifiers', the following is mentioned: iterator insert(iterator position, const T& x); void insert(iterator position, size_type n, const T& x); template <class InputIterator> void insert(iterator position, InputIterator first, InputIterator last);
0
9706
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
9579
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
10577
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...
1
10320
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9150
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...
1
7620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2991
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.