Subject: [Boost-bugs] [Boost C++ Libraries] #7391: phoenix::insert compile fails with libc++
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-19 07:32:14
#7391: phoenix::insert compile fails with libc++
-------------------------------------+--------------------------------------
Reporter: Naomasa Matsubayashi | Owner: theller
Type: Bugs | Status: new
Milestone: To Be Determined | Component: phoenix
Version: Boost Development Trunk | Severity: Problem
Keywords: |
-------------------------------------+--------------------------------------
Following code produces a compile error with libc++.
{{{
#include <vector>
#include <boost/phoenix.hpp>
int main() {
std::vector< int > hoge;
std::vector< int > fuga;
namespace phx = boost::phoenix;
phx::insert( phx::placeholders::_1, phx::placeholders::_2, fuga.begin(),
fuga.end() )( hoge, hoge.end() );
}
}}}
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] )
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.
{{{
void function 'operator()' should not return a value [-Wreturn-type]
return c.insert(arg1, arg2, arg3);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
}}}
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 :(
{{{
--- boost/phoenix/stl/container/container.hpp
+++ boost/phoenix/stl/container/container.hpp
@@ -425,6 +425,9 @@
choice_1;
typedef
+#ifdef _LIBCPP_VERSION
+ iterator_of<C>
+#else
boost::mpl::eval_if_c<
boost::mpl::and_<
boost::is_same<Arg3, mpl::void_>
@@ -433,8 +436,8 @@
, iterator_of<C>
, boost::mpl::identity<void>
>
+#endif
choice_2;
-
public:
typedef typename
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7391> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC