首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用VS 2015社区编译boost.type_erasure时的模糊调用

使用VS 2015社区编译boost.type_erasure时的模糊调用
EN

Stack Overflow用户
提问于 2015-08-31 12:10:17
回答 1查看 72关注 0票数 0

我尝试在空闲函数‘`foo’上使用(版本1.59),如下所示。

代码语言:javascript
复制
#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社区提供了以下错误信息。

代码语言:javascript
复制
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)'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-02 02:46:52

根据来自Boost用户邮件列表的响应,它是由VS的可变模板错误引起的。代码通过定义BOOST_NO_CXX11_VARIADIC_TEMPLATES进行编译。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32310932

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档