Boost C++ Libraries

...one 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.
PrevUpHomeNext

Chapter 11. Boost.Function

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 http://www.boost.org/LICENSE_1_0.txt)

Table of Contents

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

Introduction

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.


PrevUpHomeNext