[type_erasure] compile error with gcc 4.8
Hi Steven, the following code used to compile with older gcc versions (I just tried with 4.5 and I used the same construct with 4.7) but no more with gcc 4.8, but I don't know whether it's a gcc or type_erasure problem (or mine). The problem seems to be with rvalue refs. If I use the commented out version, it compiles fine on both compilers. Any idea? If you have no gcc 4.8, I can attach the error. Thanks, Christophe #include <iostream> #include <boost/type_erasure/any.hpp> #include <boost/type_erasure/builtin.hpp> #include <boost/type_erasure/operators.hpp> #include <boost/type_erasure/constructible.hpp> #include <boost/type_erasure/relaxed.hpp> #include <boost/type_erasure/member.hpp> #include <boost/mpl/vector.hpp> #include <boost/function.hpp> BOOST_TYPE_ERASURE_MEMBER((has_post), post); struct any_post_concept: ::boost::mpl::vector< //has_post<void(boost::function<void()>), const boost::type_erasure::_self>, has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, boost::type_erasure::relaxed, boost::type_erasure::copy_constructible<>
{} ; typedef boost::type_erasure::any<any_post_concept> any_post;
struct any_impl { //void post(boost::function<void()> f)const {f();} void post(boost::function<void()> && f)const {f();} }; int main() { any_impl s; any_post p (s); boost::function<void()> f = [](){std::cout << "ok" << std::endl;}; //p.post(f); p.post(std::move(f)); return 0; }
*ping*
Hi Steven,
the following code used to compile with older gcc versions (I just tried with 4.5 and I used the same construct with 4.7) but no more with gcc 4.8, but I don't know whether it's a gcc or type_erasure problem (or mine). The problem seems to be with rvalue refs. If I use the commented out version, it compiles fine on both compilers. Any idea? If you have no gcc 4.8, I can attach the error.
Thanks, Christophe
#include <iostream>
#include <boost/type_erasure/any.hpp> #include <boost/type_erasure/builtin.hpp> #include <boost/type_erasure/operators.hpp> #include <boost/type_erasure/constructible.hpp> #include <boost/type_erasure/relaxed.hpp> #include <boost/type_erasure/member.hpp>
#include <boost/mpl/vector.hpp> #include <boost/function.hpp>
BOOST_TYPE_ERASURE_MEMBER((has_post), post);
struct any_post_concept: ::boost::mpl::vector< //has_post<void(boost::function<void()>), const boost::type_erasure::_self>, has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, boost::type_erasure::relaxed, boost::type_erasure::copy_constructible<>
{} ; typedef boost::type_erasure::any<any_post_concept> any_post;
struct any_impl { //void post(boost::function<void()> f)const {f();} void post(boost::function<void()> && f)const {f();} };
int main() { any_impl s; any_post p (s); boost::function<void()> f = [](){std::cout << "ok" << std::endl;}; //p.post(f); p.post(std::move(f)); return 0; }
I only have gcc 4.7
In Christ, Steven Watanabe
With 4.8.0 I get this, in case it helps. Thanks, Christophe In file included from any.cpp:8:0: any.cpp: In instantiation of 'typename boost::type_erasure::rebind_any<Base, R>::type boost::type_erasure::concept_interface<has_post<R(A ...), T>, Base, typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type, Enable>::post(typename boost::type_erasure::as_param<Base, A>::type ...) const [with R = void; A = {boost::function<void()>&&}; T = const boost::type_erasure::_self; Base = boost::type_erasure::concept_interface<boost::type_erasure::copy_constructible<>, boost::type_erasure::concept_interface<boost::type_erasure::constructible<boost::type_erasure::_self(const boost::type_erasure::_self&)>, boost::type_erasure::concept_interface<boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::any_base<boost::type_erasure::any<any_post_concept> >, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>; Enable = void; typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type = boost::type_erasure::_self; typename boost::type_erasure::rebind_any<Base, R>::type = void]': any.cpp:37:24: required from here /data/boost_1_52_0/boost/type_erasure/member.hpp:194:66: error: no matching function for call to 'call(has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, const boost::type_erasure::concept_interface<has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, boost::type_erasure::concept_interface<boost::type_erasure::copy_constructible<>, boost::type_erasure::concept_interface<boost::type_erasure::constructible<boost::type_erasure::_self(const boost::type_erasure::_self&)>, boost::type_erasure::concept_interface<boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::any_base<boost::type_erasure::any<any_post_concept> >, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>&, boost::function<void()>)' *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N)); \ ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:239:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_II' BOOST_TYPE_ERASURE_MEMBER_II(namespace_name, concept_name, member, N) ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:127:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_I' BOOST_TYPE_ERASURE_MEMBER_I( \ ^ any.cpp:13:1: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER' BOOST_TYPE_ERASURE_MEMBER((has_post), post); ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:194:66: note: candidates are: *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N)); \ ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:239:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_II' BOOST_TYPE_ERASURE_MEMBER_II(namespace_name, concept_name, member, N) ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:127:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_I' BOOST_TYPE_ERASURE_MEMBER_I( \ ^ any.cpp:13:1: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER' BOOST_TYPE_ERASURE_MEMBER((has_post), post); ^ In file included from /data/boost_1_52_0/boost/type_erasure/constructible.hpp:21:0, from /data/boost_1_52_0/boost/type_erasure/builtin.hpp:17, from /data/boost_1_52_0/boost/type_erasure/detail/normalize.hpp:34, from /data/boost_1_52_0/boost/type_erasure/any.hpp:36, from any.cpp:3: /data/boost_1_52_0/boost/type_erasure/call.hpp:403:1: note: template<class Concept, class Op, class ... U> typename boost::type_erasure::detail::call_result<Op, void(U&& ...), Concept>::type boost::type_erasure::call(const boost::type_erasure::binding<Concept>&, const Op&, U&& ...) call( ^ /data/boost_1_52_0/boost/type_erasure/call.hpp:403:1: note: template argument deduction/substitution failed: In file included from any.cpp:8:0: /data/boost_1_52_0/boost/type_erasure/member.hpp:194:66: note: 'has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>' is not derived from 'const boost::type_erasure::binding<Concept>' *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N)); \ ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:239:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_II' BOOST_TYPE_ERASURE_MEMBER_II(namespace_name, concept_name, member, N) ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:127:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_I' BOOST_TYPE_ERASURE_MEMBER_I( \ ^ any.cpp:13:1: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER' BOOST_TYPE_ERASURE_MEMBER((has_post), post); ^ In file included from /data/boost_1_52_0/boost/type_erasure/constructible.hpp:21:0, from /data/boost_1_52_0/boost/type_erasure/builtin.hpp:17, from /data/boost_1_52_0/boost/type_erasure/detail/normalize.hpp:34, from /data/boost_1_52_0/boost/type_erasure/any.hpp:36, from any.cpp:3: /data/boost_1_52_0/boost/type_erasure/call.hpp:436:1: note: template<class Op, class ... U> typename boost::type_erasure::detail::call_result<Op, void(U&& ...)>::type boost::type_erasure::call(const Op&, U&& ...) call( ^ /data/boost_1_52_0/boost/type_erasure/call.hpp:436:1: note: template argument deduction/substitution failed: /data/boost_1_52_0/boost/type_erasure/call.hpp: In substitution of 'template<class Op, class ... U> typename boost::type_erasure::detail::call_result<Op, void(U&& ...)>::type boost::type_erasure::call(const Op&, U&& ...) [with Op = has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>; U = {const boost::type_erasure::concept_interface<has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, boost::type_erasure::concept_interface<boost::type_erasure::copy_constructible<boost::type_erasure::_self>, boost::type_erasure::concept_interface<boost::type_erasure::constructible<boost::type_erasure::_self(const boost::type_erasure::_self&)>, boost::type_erasure::concept_interface<boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::any_base<boost::type_erasure::any<any_post_concept, boost::type_erasure::_self> >, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>&, boost::function<void()>}]': any.cpp:13:1: required from 'typename boost::type_erasure::rebind_any<Base, R>::type boost::type_erasure::concept_interface<has_post<R(A ...), T>, Base, typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type, Enable>::post(typename boost::type_erasure::as_param<Base, A>::type ...) const [with R = void; A = {boost::function<void()>&&}; T = const boost::type_erasure::_self; Base = boost::type_erasure::concept_interface<boost::type_erasure::copy_constructible<>, boost::type_erasure::concept_interface<boost::type_erasure::constructible<boost::type_erasure::_self(const boost::type_erasure::_self&)>, boost::type_erasure::concept_interface<boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::any_base<boost::type_erasure::any<any_post_concept> >, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>; Enable = void; typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type = boost::type_erasure::_self; typename boost::type_erasure::rebind_any<Base, R>::type = void]' any.cpp:37:24: required from here /data/boost_1_52_0/boost/type_erasure/call.hpp:436:1: error: no type named 'type' in 'struct boost::type_erasure::detail::call_result<has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, void(const boost::type_erasure::concept_interface<has_post<void(boost::function<void()>&&), const boost::type_erasure::_self>, boost::type_erasure::concept_interface<boost::type_erasure::copy_constructible<>, boost::type_erasure::concept_interface<boost::type_erasure::constructible<boost::type_erasure::_self(const boost::type_erasure::_self&)>, boost::type_erasure::concept_interface<boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::any_base<boost::type_erasure::any<any_post_concept> >, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>&, boost::function<void()>&&), void>' In file included from any.cpp:8:0: any.cpp: In instantiation of 'typename boost::type_erasure::rebind_any<Base, R>::type boost::type_erasure::concept_interface<has_post<R(A ...), T>, Base, typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type, Enable>::post(typename boost::type_erasure::as_param<Base, A>::type ...) const [with R = void; A = {boost::function<void()>&&}; T = const boost::type_erasure::_self; Base = boost::type_erasure::concept_interface<boost::type_erasure::copy_constructible<>, boost::type_erasure::concept_interface<boost::type_erasure::constructible<boost::type_erasure::_self(const boost::type_erasure::_self&)>, boost::type_erasure::concept_interface<boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::any_base<boost::type_erasure::any<any_post_concept> >, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>; Enable = void; typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type = boost::type_erasure::_self; typename boost::type_erasure::rebind_any<Base, R>::type = void]': any.cpp:37:24: required from here /data/boost_1_52_0/boost/type_erasure/member.hpp:194:66: error: return-statement with a value, in function returning 'void' [-fpermissive] *this BOOST_TYPE_ERASURE_MEMBER_FORWARD_REBIND(N)); \ ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:239:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_II' BOOST_TYPE_ERASURE_MEMBER_II(namespace_name, concept_name, member, N) ^ /data/boost_1_52_0/boost/type_erasure/member.hpp:127:5: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER_I' BOOST_TYPE_ERASURE_MEMBER_I( \ ^ any.cpp:13:1: note: in expansion of macro 'BOOST_TYPE_ERASURE_MEMBER' BOOST_TYPE_ERASURE_MEMBER((has_post), post); ^
participants (2)
-
Christophe Henry
-
Steven Watanabe