Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.


Douglas Gregor

Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

Table of Contents

History & Compatibility Notes
Basic Usage
Free functions
Member functions
References to Function Objects
Comparing Boost.Function function objects
Header <boost/function.hpp>
Header <boost/function_equal.hpp>
Frequently Asked Questions
Miscellaneous Notes
Boost.Function vs. Function Pointers
Combatting virtual function "bloat"
Acceptance tests
Negative tests


The Boost.Function library contains a family of class templates that are function object wrappers. The notion is similar to a generalized callback. It shares features with function pointers in that both define a call interface (e.g., a function taking two integer arguments and returning a floating-point value) through which some implementation can be called, and the implementation that is invoked may change throughout the course of the program.

Generally, any place in which a function pointer would be used to defer a call or make a callback, Boost.Function can be used instead to allow the user greater flexibility in the implementation of the target. Targets can be any 'compatible' function object (or function pointer), meaning that the arguments to the interface designated by Boost.Function can be converted to the arguments of the target function object.

Last revised: July 25, 2004 at 02:51:51 GMT