---
name: "Func_ptr_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/Func_ptr_functors"
---

# Func\_ptr\_functors(3)

## NAME

Adaptors for pointers to functions -

## Detailed Description

The advantage of function objects over pointers to functions is that the objects in the standard library declare nested typedefs describing their argument and result types with uniform names (e.g., `result_type` from the base classes **unary\_function and binary\_function). Sometimes those typedefs are required, not just optional.**

**Adaptors are provided to turn pointers to unary (single-argument) and binary (double-argument) functions into function objects. The long-winded functor pointer\_to\_unary\_function is constructed with a function pointer** `f`**, and its** `operator()` **called with argument** `x` **returns** `f(x)`**. The functor pointer\_to\_binary\_function does the same thing, but with a double-argument** `f` **and** `operator()`**.**

**The function** `ptr_fun` **takes a pointer-to-function** `f` **and constructs an instance of the appropriate functor.**

### Classes

class **pointer\_to\_binary\_function**\
 *One of the* **adaptors for function pointers***.*  class **pointer\_to\_unary\_function**\
 *One of the* **adaptors for function pointers***.*

### Functions

template\<class \_Arg1, class \_Arg2, class \_Result\> pointer\_to\_binary\_function\< \_Arg1, \_Arg2, \_Result \> **ptr\_fun** (\_Result(\*\_\_x)(\_Arg1, \_Arg2))\
 template\<class \_Arg, class \_Result\> pointer\_to\_unary\_function\< \_Arg, \_Result \> **ptr\_fun** (\_Result(\*\_\_x)(\_Arg))\

## Function Documentation

### pointer\_to\_binary\_function\<\_Arg1, \_Arg2, \_Result\> std::ptr\_fun (\_Result(\*)(\_Arg1, \_Arg2) \_\_x)` [inline]`

**One of the adaptors for function pointers.**

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

### pointer\_to\_unary\_function\<\_Arg, \_Result\> std::ptr\_fun (\_Result(\*)(\_Arg) \_\_x)` [inline]`

**One of the adaptors for function pointers.**

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