FBB::Reverse(3bobcat)

πŸ’– FBB::Reverse πŸ’–

(straight outta the bobcat manual pages, section 3 β€” bestie edition)

✨ NAME ✨

FBB::Reverse β€” a class template offering reverse iterators. that's it. that's the whole vibe. πŸ‘‘


✨ SYNOPSIS ✨

#include <bobcat/reverse>

✨ DESCRIPTION ✨

okay so here's the situation. not every data type that offers (or implicitly provides) iterators also offers reverse_iterators. arrays? they don't. πŸ’€ initializer_lists? also no. now, you can use pointers to array elements instead of iterators, but the catch is you literally cannot use arrays in range-based for-loops. tragic.

enter the Ranger class (peep ranger(3bobcat)) β€” it can be used for defining begin and end members, which lets arrays show up in range-based for-loops. and when you use Reverse objects, your data structures can be used in range-based for-loops and/or to obtain reverse-iterators so you can visit data elements in reversed order. backwards slay. πŸ”₯

the class templates Reverse, ReverseArray, and ReverseSize are normally not directly used β€” instead they're returned by the various reverse support functions. these three classes offer two members: begin, which returns a reverse_iterator to the end of the data range of the object passed to reverse, and end, which returns a reverse_iterator to the beginning of the data range of the object passed to reverse.


✨ NAMESPACE ✨

FBB

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


✨ INHERITS FROM ✨

-

(nothing bestie, it inherits from nothing, main character energy from birth πŸ’…)


✨ REVERSE FUNCTIONS ✨

  • reverse(Type &object) β€” returns a Reverse object offering reverse iterators to the data range of object, which must support begin and end members. if Type is a constant type, then Reverse's begin and end members return const_reverse_iterators, otherwise reverse_iterators are returned.
  • reverse(Type (&array)[size]) β€” returns a Reverse object offering reverse iterators to the reversed range of elements of array. if Type is a constant type, then Reverse's begin and end members return const_reverse_iterators, otherwise reverse_iterators are returned.
  • reverse(Type *array, size_t size) β€” returns a Reverse object offering reverse iterators to the reversed range of elements of array to array + size. if Type is a constant type, then Reverse's begin and end members return const_reverse_iterators, otherwise reverse_iterators are returned.

✨ EXAMPLE ✨

look at her go πŸ¦‹

#include <iostream>
#include <vector>

#include <bobcat/reverse>

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 << ' ';
    cout << '\n';

    for (int value: reverse(intArr, 5))     // using specified sizes
        cout << value << ' ';
    cout << '\n';

    int const constArr[] = { 1, 2, 3, 4, 5};// arrays with const elements
    for (int value: reverse(constArr))
        cout << value << ' ';
    cout << '\n';

    for (int value: reverse(constArr, 5))   // using specified sizes
        cout << value << ' ';
    cout << '\n';

    for (int value: reverse(intArr, 5))     // arrays of specified sizes
        cout << value << ' ';
    cout << '\n';

    vector<int> vi{ 1, 2, 3, 4, 5 };        // handle non-const objects
    for (int value: reverse(vi))
        cout << value << ' ';
    cout << '\n';

    vector<int> const cvi{ 1, 2, 3, 4, 5 }; // handle const objects
    for (int value: reverse(cvi))
        cout << value << ' ';
    cout << '\n';
                                            // handle lvalues
    for (int value: reverse(initializer_list<int>{ 1, 2, 4, 8 }))
        cout << value << ' ';
    cout.put('\n');
                                            // named constant objects
    auto ilist = initializer_list<int>{ 1, 2, 4, 8 };
    for (int value: reverse(ilist))
        cout << value << ' ';
    cout.put('\n');
}

✨ FILES ✨

  • bobcat/reverse β€” defines the class interfaces and declares the reverse functions.

✨ SEE ALSO ✨

bobcat(7), ranger(3bobcat)


✨ BUGS ✨

None Reported. (not a single one, we're flawless, no cap πŸ™ˆβœ¨)


✨ BOBCAT PROJECT FILES ✨

Debian Bobcat project files:

  • libbobcat6: debian package containing the shared library, changelog and copyright note;
  • libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;

✨ BOBCAT ✨

Bobcat is an acronym of Brokken's Own Base Classes And Templates. iconic naming ngl πŸ‘‘


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


✨ AUTHOR ✨

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


πŸ’Œ and that's a wrap bestie!! this page lives in libbobcat-dev_6.15.01, dated 2005-2026, so if you ever need to cite it or find it again, that's your receipt. go reverse something. periodt. πŸ’…πŸ’–πŸŽ€
πŸ“¦ where this page comes from