GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  RANGER (3)

NAME

FBB::Ranger - generalizes ranges for range-based for-loops

CONTENTS

SYNOPSIS

#include <bobcat/ranger>

DESCRIPTION

The Ranger class template defines ranges that can be used with range-based for-loops. The standard range-based for-loop requires for its range-specificiation an array or an iterator range as offered by, e.g., containers (through their begin and end members). Ranges defined by a pair of pointers or by a subrange defined by iterator expressions cannot currently be used in combination with range-based for-loops.

Ranger extends the applicability of range-based for-loops by turning pairs of pointers, an initial pointer and a pointer count, or a pair of iterators into a range that can be used by range-based for-loops.

Ranger is a class template requiring one template type parameter: Iterator, an iterator or pointer type reaching the data when dereferenced.

Ranger\(cqs users don\(cqt have to specify Ranger\(cqs template type. The function template ranger returns the appropriate Ranger object.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

FREE FUNCTION

When using the following free functions, any (subrange) of iterators or pointers can be used. With iterators subranges of reverse iterators can also be specified. The EXAMPLE section below illustrates the use of the ranger function templates.
o Ranger<Iterator> ranger(Iterator &&begin, Iterator &&end):
this function template returns a Ranger object for the (sub)range defined by two (reverse) iterators;
o Ranger<Iterator> ranger(Iterator &&begin, size_t count):
this function template returns a Ranger object for the (sub)range defined by the (reverse) iterator range begin and begin + count;
o Ranger<Data *> ranger(Data *begin, Data *end):
this function template returns a Ranger object for the (sub)range defined by the two pointers begin and end;
o Ranger<Data *> ranger(Data *begin, size_t count):
this function template returns a Ranger object for the (sub)range defined by the two pointers begin and begin + count.

CONSTRUCTORS

Below, Iterator refers to the Ranger class template\(cqs type parameter. Although named \(cqIterator\(cq it can also be a pointer to some data type (e.g., std::string *).
o Ranger(Iterator const &begin, Iterator const &end):
A Ranger object can be passed as range-specifier in a range-based for-loop. All elements defined by the range will subsequently be visited by the range-based for-loop. The copy and move constructors are available.

OVERLOADED OPERATORS

The copy and move assignment operators are available.

MEMBER FUNCTIONS

o Iterator const &begin() const:
returns (a copy of) the begin iterator passed to the Ranger\(cqs constructor. Note that if Iterator was a pointer type (like int *) the data to which the iterator returned by begin() can actually be modified, as the member\(cqs return type (using int * for Iterator) becomes int * const &, so a reference to a constant pointer to an int. This is perfectly OK: if the data themselves should be immutable, then the data type must be defined as int const, which is automatically the case when passing int const * data. See the EXAMPLE section for an illustration.
o Iterator const &end() const:
returns (a copy of) the end iterator passed to the Ranger\(cqs constructor. If reverse iterators are passed to Ranger\(cqs constructor, then the begin and end members return reverse iterators. Since the intended use of Ranger objects is to define a range for range-base for-loops, members like rbegin and rend can be omitted from Ranger.

EXAMPLE

#include <vector>
#include <iostream>

#include <bobcat/ranger>

using namespace std; using namespace FBB;

int main() { vector<int> iv {1, 2, 3, 4, 5}; // display and modify a subrange for(auto &el: ranger(iv.rbegin() + 1, iv.rend() - 1)) cout << el++ << \(cq \(cq; cout << \(cq\n\(cq; // display a reversed range for(auto &el: ranger(iv.rbegin() + 1, iv.rend() - 1)) cout << el << \(cq \(cq; cout << \(cq\n\(cq; // same: display using a count for(auto &el: ranger(iv.rbegin() + 1, 3)) cout << el << \(cq \(cq; cout << \(cq\n\(cq;

int intArray[] = {1, 2, 3, 4, 5}; // display and modify elements // in a pointer-based range for(auto &el: ranger(intArray + 1, intArray + 3)) cout << el++ << \(cq \(cq; cout << \(cq\n\(cq; // data now modified for(auto &el: ranger(intArray + 1, intArray + 3)) cout << el << \(cq \(cq; cout << \(cq\n\(cq; // using a count rather than an // end-pointer for(auto &el: ranger(intArray + 1, 3)) cout << el << \(cq \(cq; cout << \(cq\n\(cq;

int const constInts[] = {1, 2, 3, 4, 5};

// data can\(cqt be modified for(auto &el: ranger(constInts + 1, constInts + 3)) cout << el << \(cq \(cq; cout << \(cq\n\(cq; }

FILES

bobcat/ranger - defines the class interface

SEE ALSO

bobcat(7)

BUGS

None Reported.

DISTRIBUTION FILES

o bobcat_3.25.01-x.dsc: detached signature;
o bobcat_3.25.01-x.tar.gz: source archive;
o bobcat_3.25.01-x_i386.changes: change log;
o libbobcat1_3.25.01-x_*.deb: debian package holding the libraries;
o libbobcat1-dev_3.25.01-x_*.deb: debian package holding the libraries, headers and manual pages;
o http://sourceforge.net/projects/bobcat: public archive location;

BOBCAT

Bobcat is an acronym of ‘Brokken\(cqs Own Base Classes And Templates\(cq.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).

Search for    or go to Top of page |  Section 3 |  Main Index


libbobcat-dev_3&.25&.01-x&.tar&.gz FBB::RANGER (3bobcat) 2005-2015

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.