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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:37:36+00:00 2026-05-27T15:37:36+00:00

Suppose I’m using std::copy of similar function as std::remove_if , … what it the

  • 0

Suppose I’m using std::copy of similar function as std::remove_if, … what it the best way to add an hook? In particular I want to log the status of the copying. At the end I want something equivalent to:

for(from begin to end iterator)
{
   do the copy of the container;
   cout << "." << flush;
}

but using std::copy

  • 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-05-27T15:37:37+00:00Added an answer on May 27, 2026 at 3:37 pm

    there’s pretty much only one way: wrapping the output iterator with your own iterator that behaves exactly the same from copy’s point of view, but internalyy also does the hook action.
    For example, this could be some operator’s implementation:

    template< class T, bool constcv >
    class HookingIterator : public std::iterator< std::forward_iterator_tag, .... >
    {
    public:
      reference operator* ()
      {
        dereference_hook();
        return *actual_iterator_member;
      }
    
      this_type& operator ++ ()
      {
        increment_hook();
        ++actual_iterator_member;
        return *this;
      }
    };
    

    in the constructor supply the actual iterator, and std::function objects (or plain functions/some interface instances if your compiler doesn’t have std::function).

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

Sidebar

Related Questions

Suppose I have a class MyClass to which I want to add certain 'observer'
Suppose you're developing a software product that has periodic releases. What are the best
Suppose you create a class names Person using the builder pattern, and suppose the
Suppose i have a cookie set in first.com say user. Now i want to
Suppose I have the following HTML snippet: <input type=text id=myinput /> Now I want
Suppose that I want to customize the indentation rules of the foton document editor,
Suppose I have a stream of [acme] objects that I want to expose via
suppose i have label and button on textbox and i want that if i
Suppose I have a module with the methods : function1,function2,function3. I want to import
Suppose I want to define an enum pointing to an array of objects. Can

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.