Apache C++ Standard Library Reference Guide

## unary_function

Library: General utilities

    Does not inherit

- Local Index
- Summary
- Synopsis
- Description
- See Also
- Standards Conformance

### Local Index

No Entries

### Summary

Function object base class for creating unary function objects

### Synopsis

    #include <functional>

    namespace std {
      template <class Arg, class Result>
      struct unary_function{
        typedef Arg argument_type;
        typedef Result result_type;
      };
    }

### Description

Function objects are objects with an `operator()` defined. They are important for the effective use of the standard library's generic algorithms, because the interface for each algorithmic template can accept either an object with an `operator()` defined or a pointer to a function. The standard library includes both a standard set of function objects and a pair of classes that you can use as the base for creating your own function objects.

Function objects that take one argument are called unary function objects. Unary function objects are required to include the typedefs `argument_type` and `result_type`. The unary_function class makes the task of creating templatized unary function objects easier by providing the necessary typedefs for a unary function object. You can create your own unary function objects by inheriting from unary_function.

### See Also

Function Objects, and Chapter 2, "Iterators," in the User's Guide

### Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 20.3.1