小编Via*_*uct的帖子

功能是模糊的,不是

xxx is ambiguous在处理我的c ++项目时得到了.由于整个项目太大而无法在这里上传,我做了一个简单的例子,弹出相同的错误信息.

#include <string>
#include <memory>

namespace a {

template <typename T, typename Target>
inline std::shared_ptr<T> getShared(Target const& t)
{
    return std::static_pointer_cast<T>(t->shared_from_this());
}

class A : public std::enable_shared_from_this<A>
{
};

}

namespace b {

template <typename T, typename Target>
inline std::shared_ptr<T> getShared(Target const& t)
{
    return std::static_pointer_cast<T>(t->shared_from_this());
}

class A : public std::enable_shared_from_this<A>
{
};

void invoke()
{
    // ERROR OCCURED!!!
    a::A* a;
    getShared<a::A>(a);

    // But this is compiled without any problem :(
    //  A* a; …
Run Code Online (Sandbox Code Playgroud)

c++ templates

8
推荐指数
1
解决办法
153
查看次数

标签 统计

c++ ×1

templates ×1