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.


BOOST_LOCAL_FUNCTION_TYPEOF — This macro expands to the type of the specified bound variable.


// In header: <boost/local_function.hpp>



This macro can be used within the local functions body to refer to the bound variable types so to declare local variables, check concepts (using Boost.ConceptCheck), etc (see the Advanced Topics section). This way the local function can be programmed entirely without explicitly specifying the bound variable types thus facilitating maintenance (e.g., if the type of a bound variable changes in the enclosing scope, the local function code does not have to change).


bound_variable_name The name of one of the local function's bound variables.

The type returned by the macro is fully qualified in that it contains the extra constant and reference qualifiers when the specified variable is bound by constant and by reference. For example, if a variable named t of type T is:

  • Bound by value using bind t then BOOST_LOCAL_FUNCTION_TYPEOF(t) is T.

  • Bound by constant value using const bind t then BOOST_LOCAL_FUNCTION_TYPEOF(t) is const T.

  • Bound by reference using bind& t then BOOST_LOCAL_FUNCTION_TYPEOF(t) is T&.

  • Bound by constant reference using const bind& t then BOOST_LOCAL_FUNCTION_TYPEOF(t) is const T&.

This macro must be prefixed by typename when used within templates.

Note: It is best to use this macro instead of Boost.Typeof so to reduce the number of times Boost.Typeof is used to deduce types (see the Advanced Topics section).

See: Advanced Topics section, BOOST_LOCAL_FUNCTION.