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 8255249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:27:40+00:00 2026-06-08T01:27:40+00:00

I’ve been reading the latest C++ spec, and I’m unable to figure out whether

  • 0

I’ve been reading the latest C++ spec, and I’m unable to figure out whether or not remove_if can be called multiple times for the same element. In particular, I’m looking at std::remove_if being called on deque iterators. So far as I can figure, there’s no reason for it to be called multiple times if all it does is simply start from the first param and iterate along till the second.

The code I’m working on uses manual reference counting and, as such, in case the remove_if predicate will return true, it’ll decrement and delete the underlying object reference. The obvious catch being that this will only work if the remove_if predicate is only called once for each element, otherwise subsequent calls will be accessing a deleted object. Something tells me this isn’t guaranteed to be OK and there will come a point where the same element will be passed to the remove_if predicate twice for a single remove_if call.

If you had some kind of crazy datastructure that implemented iterators and say, randomly selected an entry for each iterator increment until it (randomly) came upon the end iterator, I could see how this would fail. But for straight-forward, standardized structures like deque, vector, and list, can a single element be passed multiple times to the predicate?

  • 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-08T01:27:42+00:00Added an answer on June 8, 2026 at 1:27 am

    According to a draft of the standard §23.3.4.6/14:

    Complexity: Exactly distance(begin(), end()) applications 
    of the corresponding predicate.
    

    Forgive me if the reference is a little off; it’s actually a first for me officially quoting it. I hope it’s the information you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.