---
name: "Binder_functors"
section: "3"
platform: "linux"
package: "libstdc++6-4.1-doc"
version: "4.1.2-25"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/Binder_functors"
---

# Binder\_functors(3)

## NAME

Binder Classes -

## Detailed Description

Binders turn functions/functors with two arguments into functors with a single argument, storing an argument to be applied later. For example, a variable `B` of type **binder1st is constructed from a functor** `f` **and an argument** `x`**. Later, B's** `operator()` **is called with a single argument** `y`**. The return value is the value of** `f(x,y)`**.** `B` **can be 'called' with various arguments (y1, y2, ...) and will in turn call** `f(x,y1)`**,** `f(x,y2)`**, ...**

**The function** `bind1st` **is provided to save some typing. It takes the function and an argument as parameters, and returns an instance of binder1st.**

**The type binder2nd and its creator function** `bind2nd` **do the same thing, but the stored argument is passed as the second parameter instead of the first, e.g.,** `bind2nd`**(std::minus\<float\>,1.3) will create a functor whose** `operator()` **accepts a floating-point number, subtracts 1.3 from it, and returns the result. (If** `bind1st` **had been used, the functor would perform '1.3 - x' instead.**

**Creator-wrapper functions like** `bind1st` **are intended to be used in calling algorithms. Their return values will be temporary objects. (The goal is to not require you to type names like std::binder1st**`<std::plus<int>>` **for declaring a variable to hold the return value from** `bind1st(std::plus<int>,5)`**.**

**These become more useful when combined with the composition functions.**

### Classes

class **binder1st**\
 *One of the* **binder functors***.*  class **binder2nd**\
 *One of the* **binder functors***.*

### Functions

template\<class \_Operation, class \_Tp\> binder1st\< \_Operation \> **bind1st** (const \_Operation &\_\_fn, const \_Tp &\_\_x)\
 template\<class \_Operation, class \_Tp\> binder2nd\< \_Operation \> **bind2nd** (const \_Operation &\_\_fn, const \_Tp &\_\_x)\

## Function Documentation

### binder1st\<\_Operation\> std::bind1st (const \_Operation & \_\_fn, const \_Tp & \_\_x)` [inline]`

**One of the binder functors.**

**Definition at line 418 of file stl\_function.h.**

### binder2nd\<\_Operation\> std::bind2nd (const \_Operation & \_\_fn, const \_Tp & \_\_x)` [inline]`

**One of the binder functors.**

**Definition at line 452 of file stl\_function.h.**
