我尝试在空闲函数‘`foo’上使用(版本1.59),如下所示。
#include <boost/type_erasure/any.hpp>
#include <boost/type_erasure/free.hpp>
void Foo(int);
BOOST_TYPE_ERASURE_FREE((HasFoo), Foo, 1)
using Type = boost::type_erasure::any<
HasFoo<void(boost::type_erasure::_self const&)>,
boost::type_erasure::_self const&
>;
void Foo(int) {}
int main() {
Type x{ 1 };
Foo(x);
return 0;
}它是根据我与GCC和CLang在coliru上的测试编写的。然而,VS 2015社区提供了以下错误信息。
Source.cpp
Source.cpp(17): error C2668: 'boost::type_erasure::injectHasFoo<R (const boost::type_erasure::_self &),Base,boost::type_erasure::index_list<0>>::Foo': ambiguous call to overloaded function
with
[
R=void,
Base=boost::type_erasure::any_base<boost::type_erasure::any<HasFoo<void (const boost::type_erasure::_self &)>,boost::type_erasure::_self &&>>
]
Source.cpp(6): note: could be 'void boost::type_erasure::injectHasFoo<R (const boost::type_erasure::_self &),Base,boost::type_erasure::index_list<0>>::Foo(eval_if_c<0,boost::type_erasure::detail::maybe_const_this_param<const boost::type_erasure::_self &,Base>,boost::type_erasure::as_param<Base,const boost::type_erasure::_self &>>::type)' [found using argument-dependent lookup]
with
[
R=void,
Base=boost::type_erasure::any_base<boost::type_erasure::any<HasFoo<void (const boost::type_erasure::_self &)>,boost::type_erasure::_self &&>>
]
Source.cpp(6): note: or 'void boost::type_erasure::injectHasFoo<R (const boost::type_erasure::_self &),Base,boost::type_erasure::index_list<0>>::Foo(eval_if_c<0,boost::type_erasure::detail::maybe_const_this_param<const boost::type_erasure::_self &,Base>,boost::type_erasure::as_param<Base,const boost::type_erasure::_self &>>::type)' [found using argument-dependent lookup]
with
[
R=void,
Base=boost::type_erasure::any_base<boost::type_erasure::any<HasFoo<void (const boost::type_erasure::_self &)>,boost::type_erasure::_self &>>
]
Source.cpp(6): note: or 'void boost::type_erasure::injectHasFoo<R (const boost::type_erasure::_self &),Base,boost::type_erasure::index_list<0>>::Foo(eval_if_c<0,boost::type_erasure::detail::maybe_const_this_param<const boost::type_erasure::_self &,Base>,boost::type_erasure::as_param<Base,const boost::type_erasure::_self &>>::type)' [found using argument-dependent lookup]
with
[
R=void,
Base=boost::type_erasure::any_base<boost::type_erasure::any<HasFoo<void (const boost::type_erasure::_self &)>,boost::type_erasure::_self>>
]
Source.cpp(6): note: or 'void boost::type_erasure::injectHasFoo<R (const boost::type_erasure::_self &),Base,boost::type_erasure::index_list<0>>::Foo(eval_if_c<0,boost::type_erasure::detail::maybe_const_this_param<const boost::type_erasure::_self &,Base>,boost::type_erasure::as_param<Base,const boost::type_erasure::_self &>>::type)' [found using argument-dependent lookup]
with
[
R=void,
Base=boost::type_erasure::any_base<boost::type_erasure::any<HasFoo<void (const boost::type_erasure::_self &)>,const boost::type_erasure::_self &>>
]
Source.cpp(13): note: or 'void Foo(int)'
Source.cpp(17): note: while trying to match the argument list '(Type)'发布于 2015-09-02 02:46:52
根据来自Boost用户邮件列表的响应,它是由VS的可变模板错误引起的。代码通过定义BOOST_NO_CXX11_VARIADIC_TEMPLATES进行编译。
https://stackoverflow.com/questions/32310932
复制相似问题