Blame boost/local_function.hpp

Packit 58578d
Packit 58578d
// Copyright (C) 2009-2012 Lorenzo Caminiti
Packit 58578d
// Distributed under the Boost Software License, Version 1.0
Packit 58578d
// (see accompanying file LICENSE_1_0.txt or a copy at
Packit 58578d
// http://www.boost.org/LICENSE_1_0.txt)
Packit 58578d
// Home at http://www.boost.org/libs/local_function
Packit 58578d
Packit 58578d
#ifndef BOOST_LOCAL_FUNCTION_HPP_
Packit 58578d
#define BOOST_LOCAL_FUNCTION_HPP_
Packit 58578d
Packit 58578d
#ifndef DOXYGEN
Packit 58578d
Packit 58578d
#include <boost/local_function/aux_/macro/decl.hpp>
Packit 58578d
#include <boost/local_function/aux_/macro/name.hpp>
Packit 58578d
#include <boost/local_function/aux_/macro/typeof.hpp>
Packit 58578d
#include <boost/local_function/aux_/preprocessor/traits/decl.hpp>
Packit 58578d
#include <boost/local_function/detail/preprocessor/line_counter.hpp>
Packit 58578d
#include <boost/local_function/detail/preprocessor/void_list.hpp>
Packit 58578d
#include <boost/config.hpp>
Packit 58578d
Packit 58578d
// PUBLIC //
Packit 58578d
Packit 58578d
#ifdef BOOST_NO_CXX11_VARIADIC_MACROS
Packit 58578d
#   define BOOST_LOCAL_FUNCTION_ID(id, declarations) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_AUX_DECL(id, 0 /* not within template */, \
Packit 58578d
                BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
Packit 58578d
                        BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST( \
Packit 58578d
                                declarations)))
Packit 58578d
#   define BOOST_LOCAL_FUNCTION(declarations) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_ID( \
Packit 58578d
                BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, declarations)
Packit 58578d
#   define BOOST_LOCAL_FUNCTION_ID_TPL(id, declarations) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_AUX_DECL(id, 1 /* within template */, \
Packit 58578d
                BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
Packit 58578d
                        BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST( \
Packit 58578d
                                declarations)))
Packit 58578d
#   define BOOST_LOCAL_FUNCTION_TPL(declarations) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_ID_TPL( \
Packit 58578d
                BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, declarations)
Packit 58578d
#else // VARIADIC
Packit 58578d
#   define BOOST_LOCAL_FUNCTION_ID(id, ...) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_AUX_DECL(id, 0 /* not within template */, \
Packit 58578d
                BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
Packit 58578d
                        BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
Packit 58578d
#   define BOOST_LOCAL_FUNCTION(...) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_ID( \
Packit 58578d
                BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, __VA_ARGS__)
Packit 58578d
#   define BOOST_LOCAL_FUNCTION_ID_TPL(id, ...) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_AUX_DECL(id, 1 /* within template */, \
Packit 58578d
                BOOST_LOCAL_FUNCTION_AUX_PP_DECL_TRAITS( \
Packit 58578d
                        BOOST_LOCAL_FUNCTION_DETAIL_PP_VOID_LIST(__VA_ARGS__)))
Packit 58578d
#   define BOOST_LOCAL_FUNCTION_TPL(...) \
Packit 58578d
        BOOST_LOCAL_FUNCTION_ID_TPL( \
Packit 58578d
                BOOST_LOCAL_FUNCTION_DETAIL_PP_LINE_COUNTER, __VA_ARGS__)
Packit 58578d
#endif // VARIADIC
Packit 58578d
Packit 58578d
#define BOOST_LOCAL_FUNCTION_NAME(qualified_name) \
Packit 58578d
    BOOST_LOCAL_FUNCTION_AUX_NAME(0 /* not within template */, qualified_name)
Packit 58578d
#define BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_name) \
Packit 58578d
    BOOST_LOCAL_FUNCTION_AUX_NAME(1 /* within template */, qualified_name)
Packit 58578d
Packit 58578d
#define BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name) \
Packit 58578d
    BOOST_LOCAL_FUNCTION_AUX_TYPEOF_TYPE(bound_variable_name)
Packit 58578d
Packit 58578d
// DOCUMENTATION //
Packit 58578d
Packit 58578d
#else // DOXYGEN
Packit 58578d
Packit 58578d
/** @file
Packit 58578d
@brief Local functions allow to program functions locally, within other
Packit 58578d
functions, and directly within the scope where they are needed.
Packit 58578d
*/
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro is used to start a local function declaration.
Packit 58578d
Packit 58578d
This macro must be used within a declarative context, it must follow the local
Packit 58578d
function result type, it must be followed by the local function body code, and
Packit 58578d
then by the @RefMacro{BOOST_LOCAL_FUNCTION_NAME} macro (see the
Packit 58578d
@RefSect{tutorial, Tutorial} and @RefSect{advanced_topics, Advanced Topics}
Packit 58578d
sections):
Packit 58578d
@code
Packit 58578d
{ // Some declarative context.
Packit 58578d
    ...
Packit 58578d
    result_type BOOST_LOCAL_FUNCTION(declarations) {
Packit 58578d
        ... // Body code.
Packit 58578d
    } BOOST_LOCAL_FUNCTION_NAME(qualified_name)
Packit 58578d
    ...
Packit 58578d
}
Packit 58578d
@endcode
Packit 58578d
Packit 58578d
As usual, exceptions specifications can be optionally programmed just after the
Packit 58578d
macro and before the body code block <c>{ ... }</c> (but the exception
Packit 58578d
specifications will only apply to the body code and not to the library code
Packit 58578d
automatically generated by the macro expansion, see the
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section).
Packit 58578d
Packit 58578d
Within templates, the special macros @RefMacro{BOOST_LOCAL_FUNCTION_TPL}
Packit 58578d
and @RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL} must be used.
Packit 58578d
Packit 58578d
@Params
Packit 58578d
@Param{declarations,
Packit 58578d
On compilers that support variadic macros\, the parameter declarations are
Packit 58578d
defined by the following grammar:
Packit 58578d
@code
Packit 58578d
    declarations:
Packit 58578d
            void | declaration_tuple | declaration_sequence
Packit 58578d
    declaration_tuple:
Packit 58578d
            declaration\, declaration\, ...
Packit 58578d
    declaration_sequence:
Packit 58578d
            (declaration) (declaration) ...
Packit 58578d
    declaration:
Packit 58578d
            bound_variable | parameter | default_value | result_type
Packit 58578d
    bound_variable:
Packit 58578d
            [const] bind [(variable_type)] [&] variable_name
Packit 58578d
    parameter:
Packit 58578d
            [auto | register] parameter_type parameter_name
Packit 58578d
    default_value:
Packit 58578d
            default parameter_default_value
Packit 58578d
    result_type:
Packit 58578d
            return function_result_type
Packit 58578d
@endcode
Packit 58578d
On compilers that do not support variadic macros\, <c>declaration_tuple</c>
Packit 58578d
cannot be used:
Packit 58578d
@code
Packit 58578d
    declarations:
Packit 58578d
            void | declaration_sequence
Packit 58578d
@endcode
Packit 58578d
Packit 58578d
(Lexical conventions: <c>token1 | token2</c> means either <c>token1</c> or
Packit 58578d
<c>token2</c>; <c>[token]</c> means either <c>token</c> or nothing;
Packit 58578d
<c>{expression}</c> means the token resulting from the expression.)
Packit 58578d
}
Packit 58578d
@EndParams
Packit 58578d
 
Packit 58578d
Note that on compilers that support variadic macros, commas can be used to
Packit 58578d
separate the declarations resembling more closely the usual C++ function
Packit 58578d
declaration syntax (this is the preferred syntax).
Packit 58578d
However, for portability, on all C++ compilers (with and without variadic
Packit 58578d
macros) the same library macros also accept parameter declarations specified as
Packit 58578d
a Boost.Preprocessor sequence separated by round parenthesis <c>()</c>.
Packit 58578d
Packit 58578d
When binding the object <c>this</c>, the special symbol <c>this_</c> needs to
Packit 58578d
be used instead of <c>this</c> as the name of the variable to bind and also
Packit 58578d
within the local function body to access the object.
Packit 58578d
(Mistakenly using <c>this</c> instead of <c>this_</c> might not always result in a compiler error and will in general result in undefined behaviour.)
Packit 58578d
Packit 58578d
The result type must either be specified just before the macro or within the
Packit 58578d
macro declarations prefixed by <c>return</c> (but not in both places).
Packit 58578d
Packit 58578d
Within the local function body it possible to access the result type using <c>result_type</c>, the type of the first parameter using <c>arg1_type</c>, the type of the second parameter using <c>arg2_type</c>, etc.
Packit 58578d
The bound variable types can be accessed using @RefMacro{BOOST_LOCAL_FUNCTION_TYPEOF}.
Packit 58578d
Packit 58578d
This macro cannot be portably expanded multiple times on the same line.
Packit 58578d
In these cases, use the @RefMacro{BOOST_LOCAL_FUNCTION_ID} macro instead.
Packit 58578d
Packit 58578d
The maximum number of local function parameters (excluding bound variables) is
Packit 58578d
specified by the configuration macro
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX}.
Packit 58578d
The maximum number of bound variables is specified by the configuration macro
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX}.
Packit 58578d
The configuration macro
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS} can be used to force
Packit 58578d
optimizations that reduce the local function call run-time overhead.
Packit 58578d
Packit 58578d
@Note Local functions are functors so they can be assigned to other functors
Packit 58578d
like <c>boost::function</c> (see Boost.Function).
Packit 58578d
Packit 58578d
@See @RefSect{tutorial, Tutorial} section,
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section,
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME}, @RefMacro{BOOST_LOCAL_FUNCTION_TPL},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_TYPEOF}, @RefMacro{BOOST_LOCAL_FUNCTION_ID},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_ARITY_MAX},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_BIND_MAX},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION(declarations)
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro is used to start a local function declaration within
Packit 58578d
templates.
Packit 58578d
Packit 58578d
This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION} when
Packit 58578d
declaring a local function within a template.
Packit 58578d
A part from that, this macro has the exact same syntax a
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION} (see @RefMacro{BOOST_LOCAL_FUNCTION} for more
Packit 58578d
information):
Packit 58578d
@code
Packit 58578d
{ // Some declarative context within a template.
Packit 58578d
    ...
Packit 58578d
    result_type BOOST_LOCAL_FUNCTION_TPL(declarations) {
Packit 58578d
        ... // Body code.
Packit 58578d
    } BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_name)
Packit 58578d
    ...
Packit 58578d
}
Packit 58578d
@endcode
Packit 58578d
Packit 58578d
Note that @RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL} must be used with this
Packit 58578d
macro instead of @RefMacro{BOOST_LOCAL_FUNCTION_NAME}.
Packit 58578d
Packit 58578d
This macro cannot be portably expanded multiple times on the same line.
Packit 58578d
In these cases, use the @RefMacro{BOOST_LOCAL_FUNCTION_ID_TPL} macro instead.
Packit 58578d
Packit 58578d
@Note C++03 does not allow to use <c>typename</c> outside templates.
Packit 58578d
This library internally manipulates types, these operations require
Packit 58578d
<c>typename</c> but only within templates.
Packit 58578d
This macro is used to indicate to the library when the enclosing scope is a
Packit 58578d
template so the library can correctly use <c>typename</c>.
Packit 58578d
Packit 58578d
@See @RefSect{tutorial, Tutorial} section, @RefMacro{BOOST_LOCAL_FUNCTION},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_ID_TPL},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION_TPL(declarations)
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro allows to declare multiple local functions on the same line.
Packit 58578d
Packit 58578d
This macro is equivalent to @RefMacro{BOOST_LOCAL_FUNCTION} but it can be
Packit 58578d
expanded multiple times on the same line if different identifiers <c>id</c> are
Packit 58578d
provided for each expansion (see the
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section).
Packit 58578d
Packit 58578d
@Params
Packit 58578d
@Param{id,
Packit 58578d
A unique identifier token which can be concatenated by the preprocessor
Packit 58578d
(<c>__LINE__</c>\, <c>local_function_number_1_on_line_123</c>\, etc).
Packit 58578d
}
Packit 58578d
@Param{declarations,
Packit 58578d
Same as the <c>declarations</c> parameter of the
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION} macro.
Packit 58578d
}
Packit 58578d
@EndParams
Packit 58578d
Packit 58578d
The @RefMacro{BOOST_LOCAL_FUNCTION_NAME} macro should be used to end each one
Packit 58578d
of the multiple local function declarations as usual (and it will specify a
Packit 58578d
unique name for each local function).
Packit 58578d
Packit 58578d
Within templates, the special macros @RefMacro{BOOST_LOCAL_FUNCTION_ID_TPL}
Packit 58578d
must be used.
Packit 58578d
Packit 58578d
@Note This macro can be useful when the local function macros are expanded
Packit 58578d
within user-defined macros (because macros all expand on the same line).
Packit 58578d
On some compilers (e.g., MSVC which supports the non-standard
Packit 58578d
<c>__COUNTER__</c> macro) it might not be necessary to use this macro but
Packit 58578d
the use of this macro when expanding multiple local function macros on the same
Packit 58578d
line is always necessary to ensure portability (this is because this library
Packit 58578d
can only portably use <c>__LINE__</c> to internally generate unique
Packit 58578d
identifiers).
Packit 58578d
Packit 58578d
@See @RefSect{advanced_topics, Advanced Topics} section,
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION}, @RefMacro{BOOST_LOCAL_FUNCTION_NAME},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_ID_TPL}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION_ID(id, declarations)
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro allows to declare multiple local functions on the same line
Packit 58578d
within templates.
Packit 58578d
Packit 58578d
This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION_TPL} when
Packit 58578d
declaring multiple local functions on the same line within a template.
Packit 58578d
A part from that, this macro has the exact same syntax as
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_TPL} (see @RefMacro{BOOST_LOCAL_FUNCTION_TPL}
Packit 58578d
for more information).
Packit 58578d
Packit 58578d
@Params
Packit 58578d
@Param{id,
Packit 58578d
A unique identifier token which can be concatenated by the preprocessor
Packit 58578d
(<c>__LINE__</c>\, <c>local_function_number_1_on_line_123</c>\, etc).
Packit 58578d
}
Packit 58578d
@Param{declarations,
Packit 58578d
Same as the <c>declarations</c> parameter of the
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_TPL} macro.
Packit 58578d
}
Packit 58578d
@EndParams
Packit 58578d
Packit 58578d
The @RefMacro{BOOST_LOCAL_FUNCTION_NAME} macro should be used to end each one
Packit 58578d
of the multiple local function declarations as usual (and it will specify a
Packit 58578d
unique name for each local function).
Packit 58578d
Packit 58578d
Outside template, the macro @RefMacro{BOOST_LOCAL_FUNCTION_ID} should be used
Packit 58578d
to declare multiple local functions on the same line.
Packit 58578d
Packit 58578d
@Note This macro can be useful when the local function macros are expanded
Packit 58578d
within user-defined macros (because macros all expand on the same line).
Packit 58578d
On some compilers (e.g., MSVC which supports the non-standard
Packit 58578d
<c>__COUNTER__</c> macro) it might not be necessary to use this macro but
Packit 58578d
the use of this macro when expanding multiple local function macros on the same
Packit 58578d
line is always necessary to ensure portability (this is because this library
Packit 58578d
can only portably use <c>__LINE__</c> to internally generate unique
Packit 58578d
identifiers).
Packit 58578d
Packit 58578d
@See @RefSect{advanced_topics, Advanced Topics} section,
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_TPL}, @RefMacro{BOOST_LOCAL_FUNCTION_NAME},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_ID}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION_ID_TPL(id, declarations)
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro is used to end a local function declaration specifying its
Packit 58578d
name.
Packit 58578d
Packit 58578d
This macro must follow the local function body code block <c>{ ... }</c>:
Packit 58578d
@code
Packit 58578d
{ // Some declarative context.
Packit 58578d
    ...
Packit 58578d
    result_type BOOST_LOCAL_FUNCTION(declarations) {
Packit 58578d
        ... // Body code.
Packit 58578d
    } BOOST_LOCAL_FUNCTION_NAME(qualified_name)
Packit 58578d
    ...
Packit 58578d
}
Packit 58578d
@endcode
Packit 58578d
Packit 58578d
Within templates, the special macros @RefMacro{BOOST_LOCAL_FUNCTION_TPL} and
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL} must be used.
Packit 58578d
Packit 58578d
@Params
Packit 58578d
@Param{qualified_name,
Packit 58578d
The name of the local function optionally qualified as follow:
Packit 58578d
@code
Packit 58578d
    name:
Packit 58578d
            [inline] [recursive] local_function_name
Packit 58578d
@endcode
Packit 58578d
(Lexical conventions: <c>token1 | token2</c> means either <c>token1</c> or
Packit 58578d
<c>token2</c>; <c>[token]</c> means either <c>token</c> or nothing;
Packit 58578d
<c>{expression}</c> means the token resulting from the expression.)
Packit 58578d
}
Packit 58578d
@EndParams
Packit 58578d
Packit 58578d
The local function name can be qualified by prefixing it with the keyword
Packit 58578d
<c>inline</c> (see the @RefSect{advanced_topics, Advanced Topics} section):
Packit 58578d
@code
Packit 58578d
    BOOST_LOCAL_FUNCTION_NAME(inline local_function_name)
Packit 58578d
@endcode
Packit 58578d
This increases the chances that the compiler will be able to inline the local
Packit 58578d
function calls (thus reducing run-time).
Packit 58578d
However, inline local functions cannot be passed as template parameters (e.g., to <c>std::for_each</c>) or assigned to other functors (e.g., to
Packit 58578d
<c>boost::function</c>).
Packit 58578d
That is true on C++03 compilers but inline local functions can instead be
Packit 58578d
passed as template parameters on C++11 compilers.
Packit 58578d
On C++11 compilers, there is no need to declare a local function lined because
Packit 58578d
this library will automatically use C++11 specific features to inline the local
Packit 58578d
function while always allowing to pass it as a template parameter.
Packit 58578d
This optimization is automatically enabled when the Boost.Config macro
Packit 58578d
<c>BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS</c> is not defined but it also be
Packit 58578d
forced using @RefMacro{BOOST_LOCAL_FUNCTION_CONFIG_LOCALS_AS_TPARAMS}.
Packit 58578d
Packit 58578d
The local function name can also be qualified by prefixing it with the
Packit 58578d
"keyword" <c>recursive</c> (see the
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section):
Packit 58578d
@code
Packit 58578d
    BOOST_LOCAL_FUNCTION_NAME(recursive local_function_name)
Packit 58578d
@endcode
Packit 58578d
This allows the local function to recursively call itself from its body (as
Packit 58578d
usual in C++).
Packit 58578d
However, recursive local functions should only be called within their
Packit 58578d
declaration scope (otherwise the result is undefined behaviour).
Packit 58578d
Finally, compilers have not been observed to be able to inline recursive local
Packit 58578d
function calls, not even when the recursive local function is also declared
Packit 58578d
inline:
Packit 58578d
@code
Packit 58578d
    BOOST_LOCAL_FUNCTION(inline recursive local_function_name)
Packit 58578d
@endcode
Packit 58578d
Packit 58578d
@Note The local function name cannot be the name of an operator
Packit 58578d
<c>operator...</c> and it cannot be the same name of another local function
Packit 58578d
declared within the same enclosing scope (but <c>boost::overloaded_function</c>
Packit 58578d
can be used to overload local functions, see
Packit 58578d
Boost.Functional/OverloadedFunction and the
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section).
Packit 58578d
Packit 58578d
@See @RefSect{tutorial, Tutorial} section,
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section,
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION},
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME_TPL}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION_NAME(qualified_name)
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro is used to end a local function declaration specifying its
Packit 58578d
name within templates.
Packit 58578d
Packit 58578d
This macro must be used instead of @RefMacro{BOOST_LOCAL_FUNCTION_NAME} when
Packit 58578d
declaring a local function within a template.
Packit 58578d
A part from that, this macro has the exact same syntax a
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME} (see @RefMacro{BOOST_LOCAL_FUNCTION_NAME}
Packit 58578d
for more information):
Packit 58578d
@code
Packit 58578d
{ // Some declarative context within a template.
Packit 58578d
    ...
Packit 58578d
    result_type BOOST_LOCAL_FUNCTION_TPL(declarations) {
Packit 58578d
        ... // Body code.
Packit 58578d
    } BOOST_LOCAL_FUNCTION_NAME_TPL(qualified_name)
Packit 58578d
    ...
Packit 58578d
}
Packit 58578d
@endcode
Packit 58578d
Packit 58578d
Note that @RefMacro{BOOST_LOCAL_FUNCTION_TPL} must be used with this macro
Packit 58578d
instead of @RefMacro{BOOST_LOCAL_FUNCTION}.
Packit 58578d
Packit 58578d
@Note C++03 does not allow to use <c>typename</c> outside templates.
Packit 58578d
This library internally manipulates types, these operations require
Packit 58578d
<c>typename</c> but only within templates.
Packit 58578d
This macro is used to indicate to the library when the enclosing scope is a
Packit 58578d
template so the library can correctly use <c>typename</c>.
Packit 58578d
Packit 58578d
@See @RefSect{tutorial, Tutorial} section,
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION_NAME}, @RefMacro{BOOST_LOCAL_FUNCTION_TPL}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION_NAME_TPL(name)
Packit 58578d
Packit 58578d
/**
Packit 58578d
@brief This macro expands to the type of the specified bound variable.
Packit 58578d
Packit 58578d
This macro can be used within the local functions body to refer to the bound
Packit 58578d
variable types so to declare local variables, check concepts (using
Packit 58578d
Boost.ConceptCheck), etc (see the @RefSect{advanced_topics, Advanced Topics}
Packit 58578d
section).
Packit 58578d
This way the local function can be programmed entirely without explicitly
Packit 58578d
specifying the bound variable types thus facilitating maintenance (e.g., if
Packit 58578d
the type of a bound variable changes in the enclosing scope, the local function
Packit 58578d
code does not have to change).
Packit 58578d
Packit 58578d
@Params
Packit 58578d
@Param{bound_variable_name,
Packit 58578d
The name of one of the local function's bound variables.
Packit 58578d
}
Packit 58578d
@EndParams
Packit 58578d
Packit 58578d
The type returned by the macro is fully qualified in that it contains the extra
Packit 58578d
constant and reference qualifiers when the specified variable is bound by
Packit 58578d
constant and by reference.
Packit 58578d
For example, if a variable named <c>t</c> of type <c>T</c> is:
Packit 58578d
@li Bound by value using <c>bind t</c> then
Packit 58578d
<c>BOOST_LOCAL_FUNCTION_TYPEOF(t)</c> is <c>T</c>.
Packit 58578d
@li Bound by constant value using <c>const bind t</c> then
Packit 58578d
<c>BOOST_LOCAL_FUNCTION_TYPEOF(t)</c> is <c>const T</c>.
Packit 58578d
@li Bound by reference using <c>bind& t</c> then
Packit 58578d
<c>BOOST_LOCAL_FUNCTION_TYPEOF(t)</c> is <c>T&</c>.
Packit 58578d
@li Bound by constant reference using <c>const bind& t</c> then
Packit 58578d
<c>BOOST_LOCAL_FUNCTION_TYPEOF(t)</c> is <c>const T&</c>.
Packit 58578d
Packit 58578d
This macro must be prefixed by <c>typename</c> when used within templates.
Packit 58578d
Packit 58578d
@Note It is best to use this macro instead of Boost.Typeof so to reduce the
Packit 58578d
number of times Boost.Typeof is used to deduce types (see the
Packit 58578d
@RefSect{advanced_topics, Advanced Topics} section).
Packit 58578d
Packit 58578d
@See @RefSect{advanced_topics, Advanced Topics} section,
Packit 58578d
@RefMacro{BOOST_LOCAL_FUNCTION}.
Packit 58578d
*/
Packit 58578d
#define BOOST_LOCAL_FUNCTION_TYPEOF(bound_variable_name)
Packit 58578d
Packit 58578d
#endif // DOXYGEN
Packit 58578d
Packit 58578d
#endif // #include guard
Packit 58578d