Boost C++ Libraries: Ticket #5645: Problem passing lambda functor to boost::bind - code does not compile https://svn.boost.org/trac10/ticket/5645 <p> I want to create lambda functor for function with more that 3 parameters. I need to access 1 param only, so I decided to use helper functor created wih boost::bind. Unfortunately code does not compile. But when I stored created lambda functor in boost::function object, it compiles fine. </p> <pre class="wiki">#include &lt;boost/lambda/lambda.hpp&gt; #include &lt;boost/lambda/bind.hpp&gt; #include &lt;boost/bind.hpp&gt; #include &lt;boost/function.hpp&gt; #include &lt;iostream&gt; using namespace boost::lambda; boost::lambda::placeholder1_type _l1; boost::lambda::placeholder2_type _l2; boost::arg&lt;1&gt; _b1; boost::arg&lt;4&gt; _b4; class IFoo { public: virtual ~IFoo() {} virtual void bar(int a, int b, int c, int d) = 0; }; class Foo : public IFoo { public: boost::function&lt;void(int, int, int, int)&gt; bar_hook; void bar(int a, int b, int c, int d) { if (bar_hook) bar_hook(a, b, c, d); } }; int main() { Foo foo; int a = -1; // This works fine boost::function&lt;void(int, int)&gt; tmp_func = (_l2, var(a) = _l1); foo.bar_hook = boost::bind(tmp_func, _b1, _b4); // This fails to compile //foo.bar_hook = boost::bind( (_l2, var(a) = _l1), _b1, _b4 ); foo.bar(1, 2, 3, 4); std::cout &lt;&lt; "a = " &lt;&lt; a &lt;&lt; std::endl; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5645 Trac 1.4.3 viboes Mon, 22 Oct 2012 22:05:19 GMT cc set https://svn.boost.org/trac10/ticket/5645#comment:1 https://svn.boost.org/trac10/ticket/5645#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> </ul> <p> Could you add the compiler error? With which compiler? </p> Ticket anonymous Tue, 19 Feb 2013 18:42:28 GMT <link>https://svn.boost.org/trac10/ticket/5645#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5645#comment:2</guid> <description> <p> Compiler: g++ (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3) </p> <p> Error message: </p> <pre class="wiki">In file included from /path/to/boost/include/boost/bind.hpp:22, from test.cc:3: /path/to/boost/include/boost/bind/bind.hpp: In instantiation of âboost::_bi::result_traits&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt; &gt;â: /path/to/boost/include/boost/bind/bind_template.hpp:15: instantiated from âboost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;â test.cc:44: instantiated from here /path/to/boost/include/boost/bind/bind.hpp:69: error: no type named âresult_typeâ in âclass boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;â In file included from /path/to/boost/include/boost/function/detail/maybe_include.hpp:33, from /path/to/boost/include/boost/function/detail/function_iterate.hpp:14, from /path/to/boost/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:67, from /path/to/boost/include/boost/function.hpp:64, from test.cc:4: /path/to/boost/include/boost/function/function_template.hpp: In static member function âstatic void boost::detail::function::void_function_obj_invoker4&lt;FunctionObj, R, T0, T1, T2, T3&gt;::invoke(boost::detail::function::function_buffer&amp;, T0, T1, T2, T3) [with FunctionObj = boost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;, R = void, T0 = int, T1 = int, T2 = int, T3 = int]â: /path/to/boost/include/boost/function/function_template.hpp:913: instantiated from âvoid boost::function4&lt;R, T1, T2, T3, T4&gt;::assign_to(Functor) [with Functor = boost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;, R = void, T0 = int, T1 = int, T2 = int, T3 = int]â /path/to/boost/include/boost/function/function_template.hpp:722: instantiated from âboost::function4&lt;R, T1, T2, T3, T4&gt;::function4(Functor, typename boost::enable_if_c&lt;boost::type_traits::ice_not::value, int&gt;::type) [with Functor = boost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;, R = void, T0 = int, T1 = int, T2 = int, T3 = int]â /path/to/boost/include/boost/function/function_template.hpp:1064: instantiated from âboost::function&lt;R(T0, T1, T2, T3)&gt;::function(Functor, typename boost::enable_if_c&lt;boost::type_traits::ice_not::value, int&gt;::type) [with Functor = boost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;, R = void, T0 = int, T1 = int, T2 = int, T3 = int]â /path/to/boost/include/boost/function/function_template.hpp:1105: instantiated from âtypename boost::enable_if_c&lt;boost::type_traits::ice_not::value, boost::function&lt;R(T0, T1, T2, T3)&gt;&amp;&gt;::type boost::function&lt;R(T0, T1, T2, T3)&gt;::operator=(Functor) [with Functor = boost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;, R = void, T0 = int, T1 = int, T2 = int, T3 = int]â test.cc:44: instantiated from here /path/to/boost/include/boost/function/function_template.hpp:153: error: no match for call to â(boost::_bi::bind_t&lt;boost::_bi::unspecified, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::comma_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;2&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::lambda_functor_base&lt;boost::lambda::other_action&lt;boost::lambda::assignment_action&gt;, boost::tuples::tuple&lt;boost::lambda::lambda_functor&lt;boost::lambda::identity&lt;int&amp;&gt; &gt;, boost::lambda::lambda_functor&lt;boost::lambda::placeholder&lt;1&gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type&gt; &gt; &gt;, boost::_bi::list2&lt;boost::arg&lt;1&gt;, boost::arg&lt;4&gt; &gt; &gt;) (int&amp;, int&amp;, int&amp;, int&amp;)â </pre> </description> <category>Ticket</category> </item> <item> <author>SirZooro <daniel@…></author> <pubDate>Tue, 19 Feb 2013 19:42:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5645#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5645#comment:3</guid> <description> <p> boost 1.53.0 still has this problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Wed, 11 Dec 2013 18:22:19 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5645#comment:4 https://svn.boost.org/trac10/ticket/5645#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Use <code>foo.bar_hook = boost::bind&lt;void&gt;( (_l2, var(a) = _l1), _b1, _b4 );</code> </p> Ticket