![]() |
Home | Libraries | People | FAQ | More |
BOOST_LOCAL_FUNCTION_NAME — This macro is used to end a local function declaration specifying its name.
// In header: <boost/local_function.hpp>
BOOST_LOCAL_FUNCTION_NAME(qualified_function_name)This macro must follow the local function body code block { ... }:
{ // Some declarative context. ... result_type BOOST_LOCAL_FUNCTION(declarations) { ... // Body code. } BOOST_LOCAL_FUNCTION_NAME(qualified_function_name) ... }
Parameters:
qualified_function_name |
The name of the local function optionally qualified as follow: qualified_function_name: [inline] [recursive] nameLexical conventions: token1 | token2 means either token1 or token2; [token] means either token or nothing; {expression} means the token resulting from the expression. |
The local function name can be qualified by prefixing it with the keyword inline (see the Advanced Topics section): BOOST_LOCAL_FUNCTION_NAME(inline name). This increases the chances that the compiler will be able to inline the local function calls (thus reducing run-time). However, inlined local functions cannot be passed as template parameters (e.g., to std::for_each) or assigned to other functors (e.g., to boost::function). That is true on C++03 compilers but inlined local functions can instead be passed as template parameters on C++11 compilers. On C++11 compilers, there is no need to declare a local function lined because this library will automatically use C++11 specific features to inline the local function while always allowing to pass it as a template parameter.
The local function name can also be qualified by prefixing it with the "keyword" recursive (see the Advanced Topics section): BOOST_LOCAL_FUNCTION_NAME(recursive name). This allows the local function to recursively call itself from its body (as usual in C++). However, compilers have not been observed to be able to inline recursive local function calls (not even when the recursive local function is also declared inline: BOOST_LOCAL_FUNCTION(inline recursive name)). Furthermore, recursive local functions should only be called within their declaration scope (otherwise the result is undefined behaviour).
Note: The local function name cannot be the name of an operator operator... and it cannot be the same name of another local function declared within the same enclosing scope (but boost::overloaded_function can be used to overload local functions, see Boost.Functional/OverloadedFunction and the Advanced Topics section).
See: Tutorial section, Advanced Topics section, BOOST_LOCAL_FUNCTION.