英特尔 C++ 编译器错误:标识符“_Compare”未定义

Error with Intel C++ compiler: identifier "_Compare" is undefined

我能够使用以下命令使用 g++ 编译以下 std=c++11 所需的代码:

g++ test.cpp -std=c++11 -Wl,-rpath,/share/apps/gcc/6.3.0/lib64

代码:

#include <chrono>
#include <map>
#include <memory>
#include <thread>
#include <utility>
int main() {
  typedef std::unique_ptr<int> intPointer;
  intPointer p(new int(10));
  std::map<int, std::unique_ptr<int>> m;
  m.insert(std::make_pair(5, std::move(p)));
  auto start = std::chrono::system_clock::now();
  if (std::chrono::system_clock::now() - start < std::chrono::seconds(2))
  {
      std::thread t;
  }
}

同样的命令(可能我不知道正确的命令)对英特尔编译器不起作用:

icpc test.cpp -std=c++11 -Wl,-rpath,/share/apps/intel/2016.1.056/vtune_amplifier_xe_2016.1.1.434111/target/linux64/lib64

错误是:

In file included from /share/apps/gcc/6.3.0/include/c++/6.3.0/map(60),
             from test.cpp(2):
/share/apps/gcc/6.3.0/include/c++/6.3.0/bits/stl_tree.h(1437): 
error: identifier "_Compare" is undefined
     && is_nothrow_move_assignable<_Compare>::value)
                                   ^

In file included from /share/apps/gcc/6.3.0/include/c++/6.3.0/map(60),
             from test.cpp(2):
/share/apps/gcc/6.3.0/include/c++/6.3.0/bits/stl_tree.h(1778): 
error: identifier "_Compare" is undefined
  _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
  ^

我做错了什么,我应该如何解决这个问题。

来自以上评论:

_Compare 是该文件中定义的 _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc> 的模板参数之一,因此肯定已定义。

更可能的原因是英特尔编译器可能不知道 is_nothrow_move_assignable 最近添加到 type_traits.

我有一个用户在使用 gcc-6.3.0 头文件和 Intel 16.1.150 编译器时遇到类似的 c++ 困难。我选择了编译器错误理论,尝试使用 Intel 17 编译器并且一切正常。 -道格

好吧,我问过英特尔代理,结果是英特尔 16 不支持 gcc6.3,英特尔 17 支持。