Boost C++ Libraries: Ticket #11705: Phoenix function defining operator() with non-const reference parameter fails to compile with C++ 11. https://svn.boost.org/trac10/ticket/11705 <p> A phoenix function object defining operator() with a non-const reference parameter does not compile when using clang version 3.5 in C++ 11 mode. </p> <p> The compiler used is: Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) </p> <p> The Boost version used is 1.59. </p> <p> A test program to illustrate the problem along with the compiler build log are provided with this bug report. </p> <p> An example of such a function object that reproduces the problem is the following: </p> <p> struct add_int_impl { typedef int result_type; </p> <p> add_int_impl(int v) { </p> <blockquote> <p> _value=v; </p> </blockquote> <p> } </p> <p> int operator()(bool&amp; flag) const { </p> <blockquote> <p> std::cout &lt;&lt; "int operator()(bool&amp; flag) called" &lt;&lt; std::endl; if (_value == 4) </p> <blockquote> <p> flag=true; </p> </blockquote> <p> return _value; </p> </blockquote> <p> } </p> <blockquote> <p> int _value; </p> </blockquote> <p> }; </p> <p> The function can be tested with the following code snippet: </p> <p> <em> <strong>* Begin code snippet </strong>* </em></p> <p> <em> Initialise the function with the value 4. </em></p> <p> boost::phoenix::function&lt;add_int_impl&gt; add_int(4); </p> <p> bool flag=false; </p> <p> BOOST_TEST(add_int(arg1)(flag) == (4)); </p> <p> <em> <strong>* End code snippet </strong>* </em></p> <p> This call will only compile under Apple's version of clang 3.5 in C++ 11 mode when one or both of the following conditions are met; </p> <p> 1) The int operator()(int a) const is also defined </p> <p> 2) One of the following flags is defined: </p> <p> BOOST_RESULT_OF_TR1 BOOST_RESULT_OF_USE_TR1_WITH_DECLTYPE_FALLBACK </p> <p> The program also compiles if the function signature is changed to use a const reference parameter, i.e. int operator()(const bool&amp; flag) const. However this then means that the parameter value cannot be modified within the body of the function as required. </p> <p> The problem does not occur if the program is compiled using C++ 98 compatibility mode. </p> <p> I suspect that the problem relates to the use of boost::result_of, which uses the decltype() function to deduce function return types when compiling with C++ 11 support. </p> <p> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11705 Trac 1.4.3 David Williams <bateyware@…> Sat, 03 Oct 2015 05:09:09 GMT attachment set https://svn.boost.org/trac10/ticket/11705 https://svn.boost.org/trac10/ticket/11705 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">phxfunction_test_problem.cpp</span> </li> </ul> <p> Small test program to illustrate the problem. </p> Ticket David Williams <bateyware@…> Sat, 03 Oct 2015 05:11:28 GMT attachment set https://svn.boost.org/trac10/ticket/11705 https://svn.boost.org/trac10/ticket/11705 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">function_testsCallsFailCompileLog.txt</span> </li> </ul> <p> clang compiler build log (Clang 3.5 with Xcode 6.2) that shows the compilation errors generated. </p> Ticket David Williams <bateyware@…> Sat, 03 Oct 2015 08:23:10 GMT attachment set https://svn.boost.org/trac10/ticket/11705 https://svn.boost.org/trac10/ticket/11705 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">updatedPhoenixFunctionProblemBuildLog.txt</span> </li> </ul> <p> Updated compiler build log that shows the errors. I have updated the log to reflect a minor change relating to the file name of the test program. </p> Ticket