Boost C++ Libraries: Ticket #7391: phoenix::insert compile fails with libc++ https://svn.boost.org/trac10/ticket/7391 <p> Following code produces a compile error with libc++. </p> <pre class="wiki">#include &lt;vector&gt; #include &lt;boost/phoenix.hpp&gt; int main() { std::vector&lt; int &gt; hoge; std::vector&lt; int &gt; fuga; namespace phx = boost::phoenix; phx::insert( phx::placeholders::_1, phx::placeholders::_2, fuga.begin(), fuga.end() )( hoge, hoge.end() ); } </pre><p> That is because phoenix::insert expects the member function insert returns void when was is called with 3 arguments. That is correct in C++03 but not in C++11.( All insert overloads returns an iterator in C++11 [23.3.7.1] ) </p> <p> Since libstdc++ returns void even if the code was compiled as C++11, the problem doesn't appear. But at least with libc++, it fails to compile and following error message is produced. </p> <pre class="wiki"> void function 'operator()' should not return a value [-Wreturn-type] return c.insert(arg1, arg2, arg3); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ </pre><p> This patch fixed the problem on libc++. I think it needs more intelligent way to detect environments those insert always return a iterator. But I don't have any good idea on that :( </p> <pre class="wiki">--- boost/phoenix/stl/container/container.hpp +++ boost/phoenix/stl/container/container.hpp @@ -425,6 +425,9 @@ choice_1; typedef +#ifdef _LIBCPP_VERSION + iterator_of&lt;C&gt; +#else boost::mpl::eval_if_c&lt; boost::mpl::and_&lt; boost::is_same&lt;Arg3, mpl::void_&gt; @@ -433,8 +436,8 @@ , iterator_of&lt;C&gt; , boost::mpl::identity&lt;void&gt; &gt; +#endif choice_2; - public: typedef typename </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7391 Trac 1.4.3 Kohei Takahashi Mon, 21 Nov 2016 13:13:09 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7391#comment:1 https://svn.boost.org/trac10/ticket/7391#comment:1 <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">fixed</span> </li> </ul> <p> It might be already fixed in <a class="ext-link" href="https://github.com/boostorg/phoenix/commit/4da68d2b04c8128b010e609697602991cbc17333"><span class="icon">​</span>4da68d2b04c8128b010e609697602991cbc17333</a>, but next (1.63) release has better implementation <a class="ext-link" href="https://github.com/boostorg/phoenix/commit/c378960d48c0b3966a3f996b0144944dca954b86"><span class="icon">​</span>c378960d48c0b3966a3f996b0144944dca954b86</a> . </p> Ticket