FBB::repeat(3bobcat)
π FBB::repeat(3bobcat) β repeated function calls π
okay bestie, come SIT. this is the bobcat manual, section 3bobcat, and today we're talking about FBB::repeat π it's a lil function template that lives in the Bobcat library and it literally just calls your function a bunch of times. that's it. that's the whole vibe. β¨
πΈ NAME πΈ
FBB::repeat β call a (member) function a fixed number of times π
π SYNOPSIS π
#include <bobcat/repeat>
β¨ DESCRIPTION β¨
so the FBB::repeat function template lets you call a function β or a member function β a certain number of times. no loops written by hand, no counting on your fingers, just vibes π¦
your functions (or member functions) are allowed to have arguments, and when you call repeat you pass those arguments in, and repeat perfectly forwards them straight to the (member) function that repeat ends up calling. perfect forwarding? yeah. she's doing it. no extra copies, no drama. π
the first argument of the repeat function template is the one that says how many times the (member) function has to be called. that's it, that's the counter. π’
and the tea β : the FBB::repeat function template is defined inline, which means the compiler is allowed to literally optimize away the repeat function call itself. iconic. the whole thing just evaporates into your code like it was never there. β¨
π«Ά NAMESPACE π«Ά
FBB
every single constructor, member, operator and manipulator mentioned in this man-page lives in the namespace FBB. periodt. π
π§ INHERITS FROM π§
-
(yeah. nothing. she inherits from nobody. she's self-made. main character energy fr fr π)
π REPEAT FUNCTION TEMPLATE π
the repeat function template is declared like this:
template <typename Counter, typename First, typename ...Params>
void repeat(Counter counter, First &&first, Params &&...params);
and in that declaration, lemme break it all the way down:
Counteris the type of the counter. usually it's anintor asize_tπ when you callrepeat,countermust be initialized to the number of timesrepeathas to call the (member) function (see below π).Firstis the prototype of a function, or the name of a class. sofirstis either the address (the name) of the function you want called, or the name of an object of class typeFirst. and in that second case β the object one β the object may or may not be aconstobject. no judgement either way. π...Paramsis the set of parameter types of the arguments that have to be perfectly forwarded to the function being called. and heads up bestie: iffirstis an object of a class type, then the first argument you pass must be the address of a member function of the classFirst. π
π EXAMPLES π
this is the whole thing, verbatim, go off:
#include <iostream>
#include <iterator>
#include <algorithm>
#include <bobcat/repeat>
using namespace std;
using namespace FBB;
class Object
{
public:
void member(int argc, char **argv) const;
void member2(size_t &rept, int argc, char **argv);
};
void Object::member(int argc, char **argv) const
{
cout << "member called\n";
copy(argv, argv + argc, ostream_iterator<char const *>(cout, "\n"));
}
void Object::member2(size_t &rept, int argc, char **argv)
{
cout << "member2 called, iteration " << rept++ << "\n";
copy(argv, argv + argc, ostream_iterator<char const *>(cout, "\n"));
}
void fun()
{
cout << "Fun called\n";
}
int main(int argc, char **argv)
{
Object object;
cout << "\n"
"*** The number of arguments determines the repeat-count ***\n\n";
cout << "Fun without arguments:\n";
repeat(argc, fun);
cout << "Object receiving argc and argv:\n";
repeat(argc, object, &Object::member, argc, argv);
cout << "Object receiving argc and argv, showing the iteration count:\n";
size_t count = 0;
repeat(argc, object, &Object::member2, count, argc, argv);
Object const obj;
cout << "Const Object receiving argc and argv:\n";
repeat(argc, obj, &Object::member, argc, argv);
}
π FILES π
bobcat/repeatβ defines the class interface π
π₯ SEE ALSO π₯
π BUGS π
okay so listen, because this one matters: be careful when using overloaded functions. the template argument resolution mechanism may straight up be unable to figure out which function it's supposed to call π that's not a vibe, that's a compile error.
and if you must use overloaded functions? you're probably gonna need a static_cast to disambiguate your intentions. yes bestie, you have to spell it out for the compiler. she's smart but she's not a mind reader. π
π BOBCAT PROJECT FILES π
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
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. cute right?? it's a backronym and it ATE. π
πΈ 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). thank you for your service king π
and that's the whole page bestie!! β¨ this was libbobcat-dev_6.15.01, dated 2005-2026, and yes she's been serving for two decades and still looks this good. no cap. now go call your functions a fixed number of times the fancy way πππ¦
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms