
I'm using mingw 4.7.2 -c -std=c++11, sandbox (83160). I'll try tomorrow with a linux gcc 4.5. Complete code: #include <boost/type_erasure/concept_interface.hpp> #include <boost/type_erasure/rebind_any.hpp> #include <boost/type_erasure/derived.hpp> #include <boost/type_erasure/is_placeholder.hpp> #include <boost/type_erasure/constructible.hpp> #include <boost/type_erasure/relaxed_match.hpp> #include <boost/type_erasure/any.hpp> #include <boost/type_erasure/builtin.hpp> #include <boost/type_erasure/any_cast.hpp> #include <boost/type_erasure/member.hpp> #include <boost/mpl/vector.hpp> #include <iostream> namespace mpl = boost::mpl; using namespace boost::type_erasure; BOOST_TYPE_ERASURE_MEMBER((n1)(has_foo), foo); struct Data{}; struct Test { void foo(Data&&)const { std::cout << "foo(Data&&) called" << std::endl; } void foo(int,double)const { std::cout << "foo(int,double) called" << std::endl; } }; int main() { Test t; any< mpl::vector< n1::has_foo<void(Data&&),const _self>, n1::has_foo<void(int, double),const _self>, copy_constructible<> > > x (t); x.foo(Data()); x.foo(1,1.0); // calls foo(int, double) return 0; } Error message: ..\testtyperasure\main.cpp: In instantiation of 'typename boost::type_erasure::rebind_any<Base, R>::type boost::type_erasure::concept_interface<n1::has_foo<R(A ...), T>, Base, typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type, typename Base::_boost_type_erasure_has_memberfoo>::foo(typename boost::type_erasure::as_param<Base, A>::type ...) const [with R = void; A = {Data&&}; T = const boost::type_erasure::_self; Base = boost::type_erasure::concept_interface<n1::has_foo<void(int, double), 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<boost::mpl::vector<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, n1::has_foo<void(int, double), const boost::type_erasure::_self>, boost::type_erasure::copy_constructible<> > >
, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>; typename Base::_boost_type_erasure_has_memberfoo = 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; typename boost::type_erasure::as_param<Base, A>::type = <type error>]': ..\testtyperasure\main.cpp:45:17: required from here ..\testtyperasure\main.cpp:19:1: error: no matching function for call to 'call(n1::has_foo<void(Data&&), const boost::type_erasure::_self>, const boost::type_erasure::concept_interface<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, boost::type_erasure::concept_interface<n1::has_foo<void(int, double), 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<boost::mpl::vector<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, n1::has_foo<void(int, double), const boost::type_erasure::_self>, boost::type_erasure::copy_constructible<> > > , boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>&, Data)' ..\testtyperasure\main.cpp:19:1: note: candidates are: In file included from ..\..\boost_1_52_0/boost/type_erasure/constructible.hpp:21:0, from ..\testtyperasure\main.cpp:5: ..\..\boost_1_52_0/boost/type_erasure/call.hpp:333: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&& ...) ..\..\boost_1_52_0/boost/type_erasure/call.hpp:333:1: note: template argument deduction/substitution failed: ..\testtyperasure\main.cpp:19:1: note: 'n1::has_foo<void(Data&&), const boost::type_erasure::_self>' is not derived from 'const boost::type_erasure::binding<Concept>' In file included from ..\..\boost_1_52_0/boost/type_erasure/constructible.hpp:21:0, from ..\testtyperasure\main.cpp:5: ..\..\boost_1_52_0/boost/type_erasure/call.hpp:366: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&& ...) ..\..\boost_1_52_0/boost/type_erasure/call.hpp:366:1: note: template argument deduction/substitution failed: ..\..\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 = n1::has_foo<void(Data&&), const boost::type_erasure::_self>; U = {const boost::type_erasure::concept_interface<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, boost::type_erasure::concept_interface<n1::has_foo<void(int, double), 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<boost::mpl::vector<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, n1::has_foo<void(int, double), const boost::type_erasure::_self>, boost::type_erasure::copy_constructible<boost::type_erasure::_self>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, 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::type_erasure::_self, void>&, Data}]': ..\testtyperasure\main.cpp:19:1: required from 'typename boost::type_erasure::rebind_any<Base, R>::type boost::type_erasure::concept_interface<n1::has_foo<R(A ...), T>, Base, typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type, typename Base::_boost_type_erasure_has_memberfoo>::foo(typename boost::type_erasure::as_param<Base, A>::type ...) const [with R = void; A = {Data&&}; T = const boost::type_erasure::_self; Base = boost::type_erasure::concept_interface<n1::has_foo<void(int, double), 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<boost::mpl::vector<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, n1::has_foo<void(int, double), const boost::type_erasure::_self>, boost::type_erasure::copy_constructible<> > > , boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>; typename Base::_boost_type_erasure_has_memberfoo = 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; typename boost::type_erasure::as_param<Base, A>::type = <type error>]' ..\testtyperasure\main.cpp:45:17: required from here ..\..\boost_1_52_0/boost/type_erasure/call.hpp:366:1: error: no type named 'type' in 'struct boost::type_erasure::detail::call_result<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, void(const boost::type_erasure::concept_interface<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, boost::type_erasure::concept_interface<n1::has_foo<void(int, double), 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<boost::mpl::vector<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, n1::has_foo<void(int, double), const boost::type_erasure::_self>, boost::type_erasure::copy_constructible<> > > , boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>&, Data&&), void>' ..\testtyperasure\main.cpp: In instantiation of 'typename boost::type_erasure::rebind_any<Base, R>::type boost::type_erasure::concept_interface<n1::has_foo<R(A ...), T>, Base, typename boost::enable_if<boost::type_erasure::detail::should_be_const<T, Base>, typename boost::remove_const<T>::type>::type, typename Base::_boost_type_erasure_has_memberfoo>::foo(typename boost::type_erasure::as_param<Base, A>::type ...) const [with R = void; A = {Data&&}; T = const boost::type_erasure::_self; Base = boost::type_erasure::concept_interface<n1::has_foo<void(int, double), 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<boost::mpl::vector<n1::has_foo<void(Data&&), const boost::type_erasure::_self>, n1::has_foo<void(int, double), const boost::type_erasure::_self>, boost::type_erasure::copy_constructible<> > > , boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>, boost::type_erasure::_self, void>; typename Base::_boost_type_erasure_has_memberfoo = 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; typename boost::type_erasure::as_param<Base, A>::type = <type error>]': ..\testtyperasure\main.cpp:45:17: required from here ..\testtyperasure\main.cpp:19:1: error: return-statement with a value, in function returning 'void' [-fpermissive]