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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:19:29+00:00 2026-06-14T02:19:29+00:00

I have been going through the boost::range library and noticed boost::range_iterator and boost::iterator_range .

  • 0

I have been going through the boost::range library and noticed boost::range_iterator and boost::iterator_range. I am confused with these terms here. Could anyone please explain what is the difference between two and when to use what? Also, it would be nice if you can point me to sample examples where the boost range library is used to know more about it apart from the documentation.

  • 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-14T02:19:30+00:00Added an answer on June 14, 2026 at 2:19 am

    Could anyone please explain what is the difference between two and when to use what?

    range_iterator is used for get type of range iterator in following way:

    range_iterator< SomeRange >::type
    

    It simillar in something to std::iterator_traits. For instance, you may get value type from iterator:

    std::iterator_traits<int*>::value_type
    

    iterator_range is bridge between ranges and iterators. For instance – you have pair of iterators, and you want pass them to algorithm which only accepts ranges. In that case you can wrap your iterators into range, using iterator_range. Or better – make_iterator_range – it will help to deduce types (like std::make_pair does):

    make_iterator_range(iterator1,iterator2)
    

    returns range.

    Consider following example:

    live demo

    #include <boost/range/iterator_range.hpp>
    #include <boost/range/algorithm.hpp>
    #include <boost/range/iterator.hpp>
    #include <typeinfo>
    #include <iostream>
    #include <ostream>
    
    using namespace boost;
    using namespace std;
    
    struct print
    {
        template<typename T>
        void operator()(const T &t) const
        {
            cout << t << " ";
        }
    };
    
    int main()
    {
        typedef int Array[20];
        cout << typeid( range_iterator<Array>::type ).name() << endl;
    
        Array arr={11,22,33,44,55,66,77,88};
        boost::for_each( make_iterator_range(arr,arr+5) ,print());
    }
    

    Also, it would be nice if you can point me to sample examples where the boost range library is used to know more about it apart from the documentation

    For quick summary – check this slides

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

Sidebar

Related Questions

have been going through here and google looking for a spellcheck solution. I see
Hi i have been going through the documentation of viewstate. http://msdn.microsoft.com/en-us/library/ms227551(v=VS.85).aspx It was mentioned
I have been going through the core jQuery code and had a few why
I need to learn couchbd and have been going through tutorials on views. I
Recently, I have been going through search trees and I encountered red-black trees, the
I am complete newbie in mod_rewrite , and I have been going through some
I have been going through the jqGrid wiki and havent been able to find
I have been going through a crash course of Ruby and Ruby on Rails
I have been going through the algorithm of uniform-cost search and even though I
I have been going through the web about this exception. I found many articles

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.