美文网首页
GetVersions报错:没有与这些操作数匹配的“<<”运算符

GetVersions报错:没有与这些操作数匹配的“<<”运算符

作者: LabVIEW_Python | 来源:发表于2022-01-17 16:12 被阅读0次

问题:在编写OpenVINO推理程序时,遇到报错:没有与这些操作数匹配的“<<”运算符,如下图所示。

没有与这些操作数匹配的“<<”运算符

原因:<<运算符不支持 std::map<std::string, Version>类型

std::map<std::string, Version> GetVersions(const std::string& deviceName) const;

解决方式:编写<< 运算符重载代码,如下所示:

#include<string>
#include<inference_engine.hpp>
#include<ngraph/ngraph.hpp>

using namespace InferenceEngine;

inline std::ostream& operator<<(std::ostream& os, const InferenceEngine::Version& version) {
    os << "\t" << version.description << " version ......... ";
    os << IE_VERSION_MAJOR << "." << IE_VERSION_MINOR << "." << IE_VERSION_PATCH;

    os << "\n\tBuild ........... ";
    os << version.buildNumber;

    return os;
}

inline std::ostream& operator<<(std::ostream& os, const InferenceEngine::Version* version) {
    if (nullptr != version) {
        os << std::endl << *version;
    }
    return os;
}

inline std::ostream& operator<<(std::ostream& os, const std::map<std::string, InferenceEngine::Version>& versions) {
    for (auto&& version : versions) {
        os << "\t" << version.first << std::endl;
        os << version.second << std::endl;
    }

    return os;
}

int main(void) {

    Core ie;
    std::cout << ie.GetVersions("CPU") << std::endl;
    return 0;
}
运行成功

相关文章

网友评论

      本文标题:GetVersions报错:没有与这些操作数匹配的“<<”运算符

      本文链接:https://www.haomeiwen.com/subject/ktvchrtx.html