【问题标题】:C++14 : No match for 'operato r='C ++ 14:'operator ='不匹配
【发布时间】:2021-05-21 02:13:24
【问题描述】:

我在这行遇到了这个问题(与运算符 = 不匹配),我无法弄清楚。

std ::shared_ptr<torch::jit::script::Module> module;

try {
module = torch::jit::load(argv[1]); //error here
}

请帮忙

【问题讨论】:

  • 我们需要更多代码来重现问题。
  • edit您的问题包括minimal reproducible example,以及fullcomplete复制粘贴(作为文本)构建输出。

标签: c++ pytorch c++14


【解决方案1】:

推广到 int 你会得到同样的错误:

#include <memory>

int main()
{
  std::shared_ptr<int> module;

  module = 10;
}

没有 operator= 因为 shared_ptr 没有该类型的它。您需要使用 std::make_shared 创建一个 Module 共享指针。

#include <memory>

int main()
{
  std::shared_ptr<int> module;

  module = std::make_shared<int>(10);

}

【讨论】:

    猜你喜欢
    • 2019-04-09
    • 2011-12-10
    • 2013-07-31
    • 1970-01-01
    • 2020-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多