.TH "FBB::Reverse" "3bobcat" "2005\-2023" "libbobcat\-dev_6\&.04\&.00" "for\-loop reverse iterators" .PP .SH "NAME" FBB::Reverse \- A class template offering reverse iterators .PP .SH "SYNOPSIS" \fB#include \fP .br .PP .SH "DESCRIPTION" .PP Not all data types offering (or implicitly providing) iterators also offer \fIreverse_iterators\fP\&. Arrays don\(cq\&t, and neither do \fIinitalizer_lists\fP\&. Pointers to array elements can be used instead of iterators, but arrays cannot be used in range\-based for\-loops\&. The \fIRanger\fP class (cf\&. \fBranger\fP(3bobcat)) can be used for defining \fIbegin\fP and \fIend\fP members allowing the use of arrays in range\-based for\-loops\&. Using \fBReverse\fP objects and data structures can be used in range\-based for\-loops and/or to obtain reverse\-iterators to visit data elements in reversed order\&. .PP The class template \fIReverse, ReverseArray,\fP and \fIReverseSize\fP are normally not directly used, but are returned by the various \fIreverse\fP support functions\&. These three classes offer two members \fIbegin\fP, returning a \fIreverse_iterator\fP to the end of the data range of the object passed to \fIreverse\fP and \fIend\fP returning a \fIreverse_iterator\fP to the beginning of the data range of the object passed to \fIreverse\fP\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \- .PP .SH "REVERSE FUNCTIONS" .IP o \fBreverse(Type &object)\fP: .br returns a \fIReverse\fP object offering reverse iterators to the data range of \fIobject\fP, which must support \fIbegin\fP and \fIend\fP members\&. If \fIType\fP is a constant type, then \fIReverse\(cq\&s begin\fP and \fIend\fP members return \fIconst_reverse_iterators\fP, otherwise \fIreverse_iterators\fP are returned; .IP .IP o \fBreverse(Type (&array)[size])\fP: .br returns a \fIReverse\fP object offering reverse iterators to the reversed range of elements of \fIarray\fP\&. If \fIType\fP is a constant type, then \fIReverse\(cq\&s begin\fP and \fIend\fP members return \fIconst_reverse_iterators\fP, otherwise \fIreverse_iterators\fP are returned; .IP .IP o \fBreverse(Type *array, size_t size)\fP: .br returns a \fIReverse\fP object offering reverse iterators to the reversed range of elements of \fIarray\fP to \fIarray + size\fP\&. If \fIType\fP is a constant type, then \fIReverse\(cq\&s begin\fP and \fIend\fP members return \fIconst_reverse_iterators\fP, otherwise \fIreverse_iterators\fP are returned\&. .SH "EXAMPLE" .nf #include #include #include using namespace std; using namespace FBB; int main() { int intArr[] = { 1, 2, 3, 4, 5}; // arrays of known sizes for (int value: reverse(intArr)) cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; for (int value: reverse(intArr, 5)) // using specified sizes cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; int const constArr[] = { 1, 2, 3, 4, 5};// arrays with const elements for (int value: reverse(constArr)) cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; for (int value: reverse(constArr, 5)) // using specified sizes cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; for (int value: reverse(intArr, 5)) // arrays of specified sizes cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; vector vi{ 1, 2, 3, 4, 5 }; // handle non\-const objects for (int value: reverse(vi)) cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; vector const cvi{ 1, 2, 3, 4, 5 }; // handle const objects for (int value: reverse(cvi)) cout << value << \(cq\& \(cq\&; cout << \(cq\&\en\(cq\&; // handle lvalues for (int value: reverse(initializer_list{ 1, 2, 4, 8 })) cout << value << \(cq\& \(cq\&; cout\&.put(\(cq\&\en\(cq\&); // named constant objects auto ilist = initializer_list{ 1, 2, 4, 8 }; for (int value: reverse(ilist)) cout << value << \(cq\& \(cq\&; cout\&.put(\(cq\&\en\(cq\&); } .fi .PP .SH "FILES" \fIbobcat/reverse\fP \- defines the class interfaces and declares the \fIreverse\fP functions\&. .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBranger\fP(3bobcat) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_6\&.04\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_6\&.04\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_6\&.04\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_6\&.04\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP