{"id":1031,"date":"2022-05-22T23:03:11","date_gmt":"2022-05-23T03:03:11","guid":{"rendered":"https:\/\/jausoft.com\/blog\/?p=1031"},"modified":"2023-01-03T01:46:23","modified_gmt":"2023-01-03T05:46:23","slug":"identifiable-cpp-function-pointer-direct_bt_pt2","status":"publish","type":"post","link":"https:\/\/jausoft.com\/blog\/2022\/05\/22\/identifiable-cpp-function-pointer-direct_bt_pt2\/","title":{"rendered":"Identifiable C++ Function Pointer of any kind in Direct-BT (Part 2)"},"content":{"rendered":"<p><a href=\"https:\/\/jausoft.com\/blog\/2022\/05\/22\/direct-bt-implementation-details-pt1\/\">Earlier I started elaborating on Direct-BT C++ implementation details<\/a>, covering communication channels and <a href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__DataStructs.html\">data structures<\/a> suitable for <a href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__Concurrency.html\">concurrency<\/a>.<\/p>\n<p>This part shall cover <a href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#details\">Jaulib&#8217;s jau::function&lt;R(A&#8230;)&gt;<\/a>, used to manage callback lists e.g. in <a href=\"https:\/\/jausoft.com\/projects\/direct_bt\/build\/documentation\/cpp\/html\/classdirect__bt_1_1BTManager.html#acc2e35b1110e1c9f5ccec131e7c28f23\">BTManager<\/a> or simply utilizing them to delegate functionality like in <a href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1service__runner.html#aae4012bed7599869aa31f14eb5380207\">jau::service_runner<\/a>.<!--more--><\/p>\n<p>Updated on 2023-01-03: Matching new class name and properties.<\/p>\n<h3>Function Overview<\/h3>\n<p>Similar to std::function, <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function&lt;R(A&#8230;)&gt;<\/a> stores any callable target function solely described by its return type <code>R<\/code> and arguments types <code>A...<\/code> from any source, e.g. free functions, capturing and non-capturing lambda function, member functions.<\/p>\n<p><a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function&lt;R(A&#8230;)&gt;<\/a> supports equality operations for all <a class=\"el\" title=\"func::target_type identifier for the target function delegate_t&lt;R, A...&gt; object, exposed by jau::func...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga28271d5ab7bc8b07be0424ff9225e70c\">func::target_type<\/a> source types, allowing to manage container of <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function<\/a>s, see <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#function_limitations\">limitations<\/a> below.<\/p>\n<p>If a <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function<\/a> contains no target, see jau::function&lt;R(A&#8230;)&gt;::is_null(), it is empty. Invoking the target of an empty <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function<\/a> is a no-operation and has no side effects.<\/p>\n<p><a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function<\/a> satisfies the requirements of CopyConstructible, CopyAssignable, MoveConstructible and MoveAssignable.<\/p>\n<p>&nbsp;<\/p>\n<p>Compared to <code>std::function&lt;R(A...)&gt;<\/code>, <code><a class=\"el\" title=\"Class template jau::function is a general-purpose static-polymorphic function wrapper.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;R(A...)&gt;<\/code><\/p>\n<ul>\n<li>exposes the target function signature <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1type__info.html#type_info\">jau::type_info<\/a> via jau::function::signature()<\/li>\n<li>supports equality operations<\/li>\n<li>supports <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1ylambda__target__t.html#ylambda_target\">Y combinator and deducing this lambda functions<\/a><\/li>\n<li>self contained low memory, cache friendly, static polymorphic target function <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html#delegate_class\">delegate_t&lt;R, A&#8230;&gt;<\/a> storage, see <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#function_impl\">implementation details<\/a><\/li>\n<li>most operations are <code>noexcept<\/code>, except for the user given function invocation<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Instances of <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_def\">jau::function<\/a> can store, copy, move and invoke any of its callable targets<\/p>\n<ul>\n<li>free functions\n<ul>\n<li>factory <a class=\"el\" title=\"Bind given non-void free-function to an anonymous function using func::free_target_t.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga0a94b96b8515d72641c6a86e794ebb38\">bind_free()<\/a>\n<ul>\n<li>includes non-capturing lambda<\/li>\n<\/ul>\n<\/li>\n<li>constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_free\">jau::function&lt;R(A&#8230;)&gt;::function(R(*func)(A&#8230;))<\/a><\/li>\n<\/ul>\n<\/li>\n<li>member functions\n<ul>\n<li>factory <a class=\"el\" title=\"Bind given class instance and non-void member function to an anonymous function using func_member_tar...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga8655dbe92935774bb151b8a2fa5748eb\">bind_member()<\/a><\/li>\n<li>constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_member\">`function(C *base, R(C::*mfunc)(A&#8230;))`<\/a><\/li>\n<\/ul>\n<\/li>\n<li>lambda functions\n<ul>\n<li>capturing and non-capturing lambdas as <a class=\"el\" title=\"Class template jau::function is a general-purpose static-polymorphic function wrapper.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a> using <a class=\"el\" title=\"func::lambda_target_t implementation for lambda closures, identifiable as func::target_type::lambda v...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1lambda__target__t.html\">func::lambda_target_t<\/a><\/li>\n<li>constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_lambda\">`template&lt;typename L&gt; function(L func)`<\/a><\/li>\n<li>see <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#function_limitations\">limitations on their equality operator w\/o RTTI on `gcc`<\/a>.<\/li>\n<\/ul>\n<\/li>\n<li><a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1ylambda__target__t.html#ylambda_target\">Y combinator and deducing this lambda functions<\/a>\n<ul>\n<li>factory <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_bind_ylambda\">bind_ylambda()<\/a><\/li>\n<\/ul>\n<\/li>\n<li>lambda alike functions using a captured data type by-reference\n<ul>\n<li>factory <a class=\"el\" title=\"Bind given data by passing the captured reference (pointer) to the value and non-void function to an ...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga27824cd82f5a539f6e811ad5f79b79eb\">bind_capref()<\/a><\/li>\n<li>constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capref\">function(I* data_ptr, R(*func)(I*, A&#8230;))<\/a><\/li>\n<\/ul>\n<\/li>\n<li>lambda alike functions using a captured data type by value\n<ul>\n<li>factory <a class=\"el\" title=\"Bind given data by copying the captured value and the given non-void function to an anonymous functio...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gab3d46ac68ef4d4de394ed9698eb43211\">bind_capval()<\/a><\/li>\n<li>constructor copy <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capval_copy\">function(const I&amp; data, R(*func)(I&amp;, A&#8230;))<\/a><\/li>\n<li>constructor move <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capval_move\">function(I&amp;&amp; data, R(*func)(I&amp;, A&#8230;))<\/a><\/li>\n<\/ul>\n<\/li>\n<li>std::function\n<ul>\n<li>factory <a class=\"el\" title=\"Bind given non-void std::function to an anonymous function using func::std_target_t.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gaf87fc19229feb71a7e5fa89ad7a816eb\">bind_std()<\/a><\/li>\n<li>constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_std\">function(uint64_t id, std::function&lt;R(A&#8230;)&gt; func)<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><a id=\"autotoc_md24\" class=\"anchor\"><\/a> Implementation Details<\/h3>\n<p><code><a class=\"el\" title=\"Class template jau::function is a general-purpose static-polymorphic function wrapper.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;R(A...)&gt;<\/code> holds the static polymorphic target function <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html#delegate_class\">delegate_t&lt;R, A&#8230;&gt;<\/a>,<br \/>\nwhich itself completely holds up to 24 bytes sized <code>TriviallyCopyable<\/code> target function objects to avoiding cache misses.<\/p>\n<p>The following table shows the full memory footprint of the target function <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html#delegate_class\">delegate_t&lt;R, A&#8230;&gt;<\/a> storage,<br \/>\nwhich equals to <code><a class=\"el\" title=\"Class template jau::function is a general-purpose static-polymorphic function wrapper.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;R(A...)&gt;<\/code> memory size as it only contains the instance of <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html\">delegate_t&lt;R, A&#8230;&gt;<\/a>.<\/p>\n<table class=\"markdownTable\">\n<tbody>\n<tr class=\"markdownTableHead\">\n<th class=\"markdownTableHeadLeft\">Type<\/th>\n<th class=\"markdownTableHeadLeft\">Signature<\/th>\n<th class=\"markdownTableHeadRight\">Target Function Size<\/th>\n<th class=\"markdownTableHeadRight\"><code>delegate_t&lt;R, A...&gt;<\/code> Size<\/th>\n<th class=\"markdownTableHeadRight\">Heap Size<\/th>\n<th class=\"markdownTableHeadRight\">Total Size<\/th>\n<th class=\"markdownTableHeadCenter\"><code>TriviallyCopyable<\/code><\/th>\n<\/tr>\n<tr class=\"markdownTableRowOdd\">\n<td class=\"markdownTableBodyLeft\">free<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;free, void ()&gt;<\/td>\n<td class=\"markdownTableBodyRight\">8<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowEven\">\n<td class=\"markdownTableBodyLeft\">member<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;member, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">16<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowOdd\">\n<td class=\"markdownTableBodyLeft\">lambda_plain<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;lambda, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">24<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowEven\">\n<td class=\"markdownTableBodyLeft\">lambda_ref<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;lambda, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">24<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowOdd\">\n<td class=\"markdownTableBodyLeft\">lambda_copy<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;lambda, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">24<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowEven\">\n<td class=\"markdownTableBodyLeft\">ylambda_plain<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;ylambda, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">24<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowOdd\">\n<td class=\"markdownTableBodyLeft\">capval (small)<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;capval, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">16<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowEven\">\n<td class=\"markdownTableBodyLeft\">capval (big)<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;capval, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">96<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<tr class=\"markdownTableRowOdd\">\n<td class=\"markdownTableBodyLeft\">capref<\/td>\n<td class=\"markdownTableBodyLeft\">function&lt;capref, int (int)&gt;<\/td>\n<td class=\"markdownTableBodyRight\">16<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyRight\">0<\/td>\n<td class=\"markdownTableBodyRight\">48<\/td>\n<td class=\"markdownTableBodyCenter\">true<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Memory sizes are in bytes, data collected on a GNU\/Linux arm64 system.<\/p>\n<p>The detailed memory footprint can queried at runtime, see implementation of <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_toString\">jau::function&lt;R(A&#8230;)&gt;::function::toString()<\/a>.<\/p>\n<p>Static polymorphism is achieved by constructing the <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html\">delegate_t&lt;R, A&#8230;&gt;<\/a> instance via their <a class=\"el\" title=\"func::target_type identifier for the target function delegate_t&lt;R, A...&gt; object, exposed by jau::func...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga28271d5ab7bc8b07be0424ff9225e70c\">func::target_type<\/a> specific factories, see mapping at <a class=\"el\" title=\"func::target_type identifier for the target function delegate_t&lt;R, A...&gt; object, exposed by jau::func...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga28271d5ab7bc8b07be0424ff9225e70c\">func::target_type<\/a>.<\/p>\n<p>For example the static <a class=\"el\" title=\"Construct a delegate_t&lt;R, A...&gt; instance from given this base-pointer and member-function.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1member__target__t.html#a0a5efd8c5026942e1b97936d4ef67cdc\">func::member_target_t::delegate<\/a> constructs its specific <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html\">delegate_t&lt;R, A&#8230;&gt;<\/a> by passing its data and required functions to <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1delegate__t.html#a334657bd07f72d535b1131d7301986ce\">func::delegate_t&lt;R, A&#8230;&gt;::make<\/a>.<br \/>\nThe latter is an overloaded template for trivial and non-trivial types and decides which memory is being used, e.g. the internal 24 bytes memory cache or heap if not fitting.<\/p>\n<p>To support lambda identity for the equality operator, <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1type__info.html#type_info\">jau::type_info<\/a> is being used either with <em>Runtime Type Information<\/em> (RTTI) if enabled or using <em>Compile time type information<\/em> (CTTI), see <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#function_limitations\">limitations<\/a> below.<\/p>\n<p>&nbsp;<\/p>\n<h3><a id=\"autotoc_md25\" class=\"anchor\"><\/a> Function Usage<\/h3>\n<p>A detailed API usage is covered within <a href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/test_functional_8hpp-example.html\">test_functional.hpp<\/a> and <a href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/test_functional_perf_8hpp-example.html\">test_functional_perf.hpp<\/a>, see function <code>test00_usage()<\/code>.<\/p>\n<p>Let&#8217;s assume we like to bind to the following function prototype <code>bool func(int)<\/code>, which results to <code><a class=\"el\" title=\"Class template jau::function is a general-purpose static-polymorphic function wrapper.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(int)&gt;<\/code>:<\/p>\n<ul>\n<li>Free functions via <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_free\">constructor<\/a> and <a class=\"el\" title=\"Bind given non-void free-function to an anonymous function using func::free_target_t.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga0a94b96b8515d72641c6a86e794ebb38\">jau::bind_free()<\/a>\n<ul>\n<li>Prologue\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">typedef<\/span> bool(*cfunc)(int); <span class=\"comment\">\/\/ to force non-capturing lambda into a free function template type deduction<\/span><\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><span class=\"keywordtype\">bool<\/span> my_func(<span class=\"keywordtype\">int<\/span> v) { <span class=\"keywordflow\">return<\/span> 0 == v; }<\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><span class=\"keyword\">struct <\/span>MyClass {<\/div>\n<div class=\"line\"><span class=\"keyword\">static<\/span> <span class=\"keywordtype\">bool<\/span> func(<span class=\"keywordtype\">int<\/span> v) { <span class=\"keywordflow\">return<\/span> 0 == v; }<\/div>\n<div class=\"line\">};<\/div>\n<\/div>\n<\/li>\n<li>Constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_free\">function(R(*func)(A&#8230;))<\/a>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func0 = my_func;<\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func1 = &amp;MyClass:func;<\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func2 = (cfunc) ( [](<span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> { <span class=\"comment\">\/\/ forced free via cast<\/span><\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">} );<\/div>\n<\/div>\n<\/li>\n<li>Factory <code><a class=\"el\" title=\"Bind given non-void free-function to an anonymous function using func::free_target_t.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga0a94b96b8515d72641c6a86e794ebb38\">jau::bind_free<\/a>(R(*func)(A...))<\/code>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func0 = <a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga0a94b96b8515d72641c6a86e794ebb38\">jau::bind_free<\/a>(&amp;MyClass:func);<\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func1 = <a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga0a94b96b8515d72641c6a86e794ebb38\">jau::bind_free<\/a>(my_func);<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>Class member functions via <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_member\">constructor<\/a> and <a class=\"el\" title=\"Bind given class instance and non-void member function to an anonymous function using func_member_tar...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga8655dbe92935774bb151b8a2fa5748eb\">jau::bind_member()<\/a>\n<ul>\n<li>Prologue\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">struct <\/span>MyClass {<\/div>\n<div class=\"line\"><span class=\"keywordtype\">bool<\/span> m_func(<span class=\"keywordtype\">int<\/span> v) { <span class=\"keywordflow\">return<\/span> 0 == v; }<\/div>\n<div class=\"line\">};<\/div>\n<div class=\"line\">MyClass i1;<\/div>\n<\/div>\n<\/li>\n<li>Constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_member\">function(C *base, R(C::*mfunc)(A&#8230;))<\/a>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func(&amp;i1, &amp;MyClass::m_func);<\/div>\n<\/div>\n<\/li>\n<li>Factory <code><a class=\"el\" title=\"Bind given class instance and non-void member function to an anonymous function using func_member_tar...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga8655dbe92935774bb151b8a2fa5748eb\">jau::bind_member<\/a>(C *base, R(C::*mfunc)(A...))<\/code>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func = <a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga8655dbe92935774bb151b8a2fa5748eb\">jau::bind_member<\/a>(&amp;i1, &amp;MyClass::m_func);<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>Lambda functions via <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_lambda\">constructor<\/a>\n<ul>\n<li>Prologue\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keywordtype\">int<\/span> sum = 0;<\/div>\n<\/div>\n<\/li>\n<li>Stateless lambda, equivalent to <code>bool(*)(int)<\/code> function\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func0 = [](<span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">};<\/div>\n<\/div>\n<\/li>\n<li>Stateless by-value capturing lambda\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func1 = [sum](<span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> sum == v;<\/div>\n<div class=\"line\">};<\/div>\n<\/div>\n<\/li>\n<li>Stateful by-value capturing lambda mutating captured field\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func1 = [sum](<span class=\"keywordtype\">int<\/span> v) <span class=\"keyword\">mutable<\/span> -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\">sum += v;<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">};<\/div>\n<\/div>\n<\/li>\n<li>Stateless by-reference capturing lambda\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func1 = [&amp;sum](<span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\">sum += v;<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">};<\/div>\n<\/div>\n<\/li>\n<li>Stateless by-reference capturing lambda assigning an auto lambda\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">auto<\/span> lambda_func = [&amp;](<span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\">sum += v;<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">};<\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func1 = lambda_func;<\/div>\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func2 = lambda_func;<\/div>\n<div class=\"line\">assert( func1 == func2 );<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li><a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1func_1_1ylambda__target__t.html#ylambda_target\">Y combinator and deducing this lambda functions<\/a> via factory <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_bind_ylambda\">bind_ylambda()<\/a>\n<ul>\n<li>Stateless lambda receiving explicit this object parameter reference used for recursion using <code>auto<\/code>\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">function<\/span>&lt;int(<span class=\"keywordtype\">int<\/span>)&gt; f = <span class=\"keyword\">function<\/span>&lt;int(<span class=\"keywordtype\">int<\/span>)&gt;::bind_ylambda( [](<span class=\"keyword\">auto<\/span>&amp; <span class=\"keyword\">self<\/span>, <span class=\"keywordtype\">int<\/span> x) -&gt; <span class=\"keywordtype\">int<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">if<\/span>( 0 == x ) {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 1;<\/div>\n<div class=\"line\">} <span class=\"keywordflow\">else<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> x * <span class=\"keyword\">self<\/span>(x-1); <span class=\"comment\">\/\/ recursion, calling itself w\/o explicitly passing `self`<\/span><\/div>\n<div class=\"line\">}<\/div>\n<div class=\"line\">} );<\/div>\n<div class=\"line\">assert( 24 == f(4) ); <span class=\"comment\">\/\/ `self` is bound to function&lt;int(int)&gt;::delegate_type `f.target`, `x` is 4<\/span><\/div>\n<\/div>\n<\/li>\n<li>or using explicit <code>function&lt;R(A...)&gt;::delegate_type<\/code>\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">function<\/span>&lt;int(<span class=\"keywordtype\">int<\/span>)&gt; f = <span class=\"keyword\">function<\/span>&lt;int(<span class=\"keywordtype\">int<\/span>)&gt;::bind_ylambda( [](<span class=\"keyword\">function<\/span>&lt;<span class=\"keywordtype\">int<\/span>(<span class=\"keywordtype\">int<\/span>)&gt;::delegate_type&amp; <span class=\"keyword\">self<\/span>, <span class=\"keywordtype\">int<\/span> x) -&gt; <span class=\"keywordtype\">int<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">if<\/span>( 0 == x ) {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 1;<\/div>\n<div class=\"line\">} <span class=\"keywordflow\">else<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> x * <span class=\"keyword\">self<\/span>(x-1); <span class=\"comment\">\/\/ recursion, calling itself w\/o explicitly passing `self`<\/span><\/div>\n<div class=\"line\">}<\/div>\n<div class=\"line\">} );<\/div>\n<div class=\"line\">assert( 24 == f(4) ); <span class=\"comment\">\/\/ `self` is bound to function&lt;int(int)&gt;::delegate_type `f.target`, `x` is 4<\/span><\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>Lambda alike capture by-reference to value via <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capref\">constructor<\/a> and <a class=\"el\" title=\"Bind given data by passing the captured reference (pointer) to the value and non-void function to an ...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga27824cd82f5a539f6e811ad5f79b79eb\">jau::bind_capref()<\/a>\n<ul>\n<li>Prologue\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">struct <\/span>big_data {<\/div>\n<div class=\"line\"><span class=\"keywordtype\">int<\/span> sum;<\/div>\n<div class=\"line\">};<\/div>\n<div class=\"line\">big_data data { 0 };<\/div>\n<div class=\"line\"><\/div>\n<div class=\"line\"><span class=\"keyword\">typedef<\/span> bool(*cfunc)(big_data*, int); <span class=\"comment\">\/\/ to force non-capturing lambda into a free function template type deduction<\/span><\/div>\n<\/div>\n<\/li>\n<li>Constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capref\">function(I* data_ptr, R(*func)(I*, A&#8230;))<\/a>\n<div class=\"fragment\">\n<div class=\"line\"><span class=\"keyword\">function<\/span>&lt;int(<span class=\"keywordtype\">int<\/span>)&gt; func(&amp;data,<\/div>\n<div class=\"line\">(cfunc) ( [](big_data* data, <span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\">stats_ptr-&gt;sum += v;<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">} ) );<\/div>\n<\/div>\n<\/li>\n<li>Factory <code><a class=\"el\" title=\"Bind given data by passing the captured reference (pointer) to the value and non-void function to an ...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga27824cd82f5a539f6e811ad5f79b79eb\">jau::bind_capref<\/a>(I* data_ptr, R(*func)(I*, A...))<\/code>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func = <a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#ga27824cd82f5a539f6e811ad5f79b79eb\">jau::bind_capref<\/a>(&amp;data,<\/div>\n<div class=\"line\">(cfunc) ( [](big_data* data, <span class=\"keywordtype\">int<\/span> v) -&gt; <span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\">stats_ptr-&gt;sum += v;<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == v;<\/div>\n<div class=\"line\">} ) );<\/div>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>Lambda alike capture by-copy of value via constructor and <a class=\"el\" title=\"Bind given data by copying the captured value and the given non-void function to an anonymous functio...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gab3d46ac68ef4d4de394ed9698eb43211\">jau::bind_capval()<\/a>\n<ul>\n<li>Constructor copy <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capval_copy\">function(const I&amp; data, R(*func)(I&amp;, A&#8230;))<\/a><\/li>\n<li>Constructor move <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_capval_move\">function(I&amp;&amp; data, R(*func)(I&amp;, A&#8230;))<\/a><\/li>\n<li>Factory copy <code><a class=\"el\" title=\"Bind given data by copying the captured value and the given non-void function to an anonymous functio...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gab3d46ac68ef4d4de394ed9698eb43211\">jau::bind_capval<\/a>(const I&amp; data, R(*func)(I&amp;, A...))<\/code><\/li>\n<li>Factory move <code><a class=\"el\" title=\"Bind given data by copying the captured value and the given non-void function to an anonymous functio...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gab3d46ac68ef4d4de394ed9698eb43211\">jau::bind_capval<\/a>(I&amp;&amp; data, R(*func)(I&amp;, A...))<\/code><br \/>\nSee example of <em>Capture by-reference to value<\/em> above.<\/li>\n<\/ul>\n<\/li>\n<li>std::function function via <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_std\">constructor<\/a> and <a class=\"el\" title=\"Bind given non-void std::function to an anonymous function using func::std_target_t.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gaf87fc19229feb71a7e5fa89ad7a816eb\">jau::bind_std()<\/a>\n<ul>\n<li>Prologue\n<div class=\"fragment\">\n<div class=\"line\">std::function&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func_stdlambda = [](<span class=\"keywordtype\">int<\/span> i)-&gt;<span class=\"keywordtype\">bool<\/span> {<\/div>\n<div class=\"line\"><span class=\"keywordflow\">return<\/span> 0 == i;<\/div>\n<div class=\"line\">};<\/div>\n<\/div>\n<\/li>\n<li>Constructor <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function_3_01R_07A_8_8_8_08_4.html#function_ctor_std\">function(uint64_t id, std::function&lt;R(A&#8230;)&gt; func)<\/a>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func(100, func_stdlambda);<\/div>\n<\/div>\n<\/li>\n<li>Factory <code><a class=\"el\" title=\"Bind given non-void std::function to an anonymous function using func::std_target_t.\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gaf87fc19229feb71a7e5fa89ad7a816eb\">jau::bind_std<\/a>(uint64_t id, std::function&lt;R(A...)&gt; func)<\/code>\n<div class=\"fragment\">\n<div class=\"line\"><a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1function.html\">jau::function<\/a>&lt;bool(<span class=\"keywordtype\">int<\/span>)&gt; func = <a class=\"code\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__FunctionWrap.html#gaf87fc19229feb71a7e5fa89ad7a816eb\">jau::bind_std<\/a>(100, func_stdlambda);<\/div>\n<\/div>\n<p>&nbsp;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><a id=\"autotoc_md26\" class=\"anchor\"><\/a> Function Limitations<\/h3>\n<h4>Non unique lambda type names without RTTI using <code>gcc<\/code> or non <code>clang<\/code> compiler<\/h4>\n<p>Due to <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__CppLang.html#ctti_name_lambda_limitations\">limitations of jau::make_ctti&lt;R, L, A&#8230;&gt;()<\/a>, <em>not using RTTI on <code>gcc<\/code> or non <code>clang<\/code> compiler<\/em> will <em>erroneously mistake<\/em> different lambda <em>functions defined within one function and using same function prototype <code>R&lt;A...&gt;<\/code><\/em> to be the same.<\/p>\n<p><a class=\"el\" title=\"Static constexpr boolean indicating whether resulting type_info uniqueness is limited for lambda func...\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1type__info.html#a536888767390a5423b432179f9edabc0\">jau::type_info::limited_lambda_id<\/a> will expose the potential limitation.<\/p>\n<p>See <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/group__CppLang.html#ctti_name_lambda_limitations\">CTTI lambda name limitations<\/a> and <a class=\"el\" href=\"https:\/\/jausoft.com\/projects\/jaulib\/build\/documentation\/cpp\/html\/classjau_1_1type__info.html#type_info_limitations\">limitations of jau::type_info<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier I started elaborating on Direct-BT C++ implementation details, covering communication channels and data structures suitable for concurrency. This part shall cover Jaulib&#8217;s jau::function&lt;R(A&#8230;)&gt;, used to manage callback lists e.g. in BTManager or simply utilizing them to delegate functionality like in jau::service_runner.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49,59,3,50,58],"tags":[53,51,52,13],"class_list":["post-1031","post","type-post","status-publish","format-standard","hentry","category-bluetooth","category-c-language","category-computer-stuff","category-direct_bt","category-computer-languages","tag-bluetooth","tag-c","tag-direct-bt","tag-embedded-device"],"_links":{"self":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/comments?post=1031"}],"version-history":[{"count":10,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1031\/revisions"}],"predecessor-version":[{"id":1127,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1031\/revisions\/1127"}],"wp:attachment":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/media?parent=1031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/categories?post=1031"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/tags?post=1031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}