Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9211167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:14:03+00:00 2026-06-18T01:14:03+00:00

Having trouble modifying a queue in a map. map<string , queue<item*> > itemList; //

  • 0

Having trouble modifying a queue in a map.

map<string , queue<item*> > itemList; // what the map creation looks like

map<string, queue<item*> >::const_iterator itr; // creating an iterator

//for every item in a warehouse
for(itr = itemList.begin(); itr != itemList.end(); ++itr)
{
    //while there are items in the queue with 1 day shelf life
    while(itr->second.front()->getLife() == 1)
    {
        //throw them away
        itr->second.pop();
    }
}

but i keep getting an error telling me this:

error: passing ‘const std::queue > >’ as ‘this’ argument of ‘std::queue > >& std::queue > >::operator=(const std::queue > >&)’ discards qualifiers

thanks in advance for any help on this one. 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:14:04+00:00Added an answer on June 18, 2026 at 1:14 am

    You are accessing the map elements via a const_iterator, so you cannot modify them (strictly speaking, you can only call const methods on the elements, and std::queue::pop() isn’t one). Try using a non-const iterator instead:

    map<string, queue<item*> >::iterator itr;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like some help with some URL rewriting magic. I am having trouble modifying
I am having trouble with modifying a php application to have pagination. My error
I'm having some trouble with modifying qTip's tip size (x,y). I tried to add
I'm having trouble modifying members of a linked list. We have a struct record
I'm having trouble with modifying the way comments are displayed. Currently they are always
I am having some trouble with modifying Strings to be space delimited under the
I'm having some trouble understanding why modifying a property in instance a modifies the
I'm having trouble modifying a script from a book (jQuery UI by Eric Sarrion),
I'm creating a lock screen app for android, but I'm having trouble getting the
I'm having trouble modifying a script that processes files passed as command line arguments,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.