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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:18:30+00:00 2026-06-12T06:18:30+00:00

I try to reuse an STL iterator, but cannot find any info about this.

  • 0

I try to reuse an STL iterator, but cannot find any info about this. Got problem in this code:

    std::vector< boost::shared_ptr<Connection> >::iterator poolbegin = pool.begin();
std::vector< boost::shared_ptr<Connection> >::iterator poolend = pool.end();
if( order ) {
    poolbegin = pool.rbegin(); // Here compilation fails
    poolend   = pool.rend();
}
    for( std::vector< boost::shared_ptr<Connection> >::iterator it = poolbegin; it<poolend; it++) {

But getting error:

error: no match for ‘operator=’ in ‘poolbegin = std::vector<_Tp,
_Alloc>::rbegin() with _Tp = boost::shared_ptr, _Alloc = std::allocator >’

Is there a way to reset iterator to new value? Like shared_ptr::reset ?

  • 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-12T06:18:31+00:00Added an answer on June 12, 2026 at 6:18 am

    It looks like you want to have a loop that goes forward or backward through a vector, depending on some condition.

    One way to do this is to factor out the loop body into a functor (or lambda if you have C++11).

    struct LoopBody {
      void operator()(boost::shared_ptr<Connection> connection) {
        // do something with the connection
      }
      // If the loop body needs to be stateful, you can add a constructor
      // that sets the initial state in member variables.
    };
    

    Now you can have two alternatives for which way you want to go through the loop:

    LoopBody loop_body;
    if (reverse_order) {
      std::for_each(pool.rbegin(), pool.rend(), loop_body);
    } else {
      std::for_each(pool.begin(), pool.end(), loop_body);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i try to reuse the lazyTableimages code but i got a problem that the
Basically the following code is causing your problem: $(sourceImageForm).find('.imagef1_upload_process').css('visibility','hidden'); $(sourceImageForm).find('.imagef1_cancel').css('visibility','hidden'); /// THIS LINE BELOW
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
Ok. Here is the full code. I tried to reuse connections setting KeepAlive but
I am trying to reuse an existing code ... but with no success .
MSDN says that after CryptVerifySignature() you cannot reuse HCRYPTHASH object to try hashing more
This is definitely subjective, but I'd like to try to avoid it becoming argumentative.
I´m starting with JavaFX and got stucked on a performace problem. I´ll try to
Note: we reuse single connection. ************************************************ public Connection connection() { try { if ((connection

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.