---
name: "repeat"
section: "3bobcat"
platform: "linux"
package: "libbobcat-dev"
version: "6.07.01-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/repeat/3bobcat"
---

# repeat(3bobcat)

call a (member) function a fixed number of times

## NAME

FBB::repeat - call a (member) function a fixed number of times

## SYNOPSIS

**#include \<bobcat/repeat\>**\

## DESCRIPTION

The **FBB::repeat** function template allows a function or member function to be called a certain number of times. The functions or member functions may define arguments. Arguments to these functions are specified when *repeat* is called, and are perfectly forwarded by the *repeat* function template to the (member) function called by *repeat*.

The first argument of the *repeat* function template defines the number of times the (member) function must be called.

The *FBB::repeat* function template are defined *inline*, allowing the compiler to \`optimize away’ the *repeat* function call itself.

## NAMESPACE

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

## INHERITS FROM

\-

## REPEAT FUNCTION TEMPLATE

The *repeat* function template is declared as:

```
template <typename Counter, typename First, typename ...Params>
void repeat(Counter counter, First &&first, Params &&...params);
```

In this declaration,

- o

  **Counter** represents the counter’s type. Usually an *int* or *size\_t*. When calling *repeat* *counter* must be initialized to the number of times *repeat* must call the (member) function (see below);

- o

  **First** represents the prototype of a function or the name of a class.  name of a class. Likewise, *first* either is the address (name) of the function to be called or the name of an object of class type *First*. In the latter case the object may or may not be a *const* object.

- o

  **...Params** represents the set of parameter types of arguments which must be perfectly forwarded to the called function. If *first* represents a class type object, the first argument *must* be the address of a member function of the class *First*.

## EXAMPLES

```
#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

[**bobcat**(7)](/bobcat/7.md)

## BUGS

Be careful when using overloaded functions, as the template argument resolution mechanism may be unable to determine which function to call. If overloaded functions must be used, a *static\_cast* is likely required to disambiguate your intentions.

## BOBCAT PROJECT FILES

- o

  *https://fbb-git.gitlab.io/bobcat/*: gitlab project page;

Debian Bobcat project files:

- o

  *libbobcat6*: debian package containing the shared library, changelog and copyright note;

- o

  *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’.

## 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**).
