c ++ 11 shared_ptr的简单示例将无法编译

时间:2014-04-07 21:45:05

标签: c++ c++11

我试图让英特尔C ++ 14.0.2编译器使用C ++ 11选项。我有这个非常简单的代码(我简化了:cplusplus.com):

// shared_ptr constructor example
#include <iostream>
#include <memory>

struct C {int* data;};

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

  std::cout << "use_count:\n";
  std::cout << "p1: " << p1.use_count() << '\n';
  return 0;
}

我尝试用英特尔C ++ 14.0.2编译器编译它,但我只是得到了这些错误:

$ icpc --std=c++11 test.cpp
test.cpp(8): error: namespace "std" has no member "shared_ptr"
    std::shared_ptr<int> p1;
         ^

test.cpp(8): error: type name is not allowed
    std::shared_ptr<int> p1;
                    ^

test.cpp(8): error: identifier "p1" is undefined
    std::shared_ptr<int> p1;
                         ^

compilation aborted for test.cpp (code 2)

(我也尝试使用-std=c++11,但遇到了同样的错误。)我使用shared_ptr错了吗?我调用编译器错了吗?这似乎是一个简单的例子,我可以想出来解释这个问题。

1 个答案:

答案 0 :(得分:3)

在英特尔支持的功能列表中,

shared_ptr未列为14.0版支持的功能之一:

http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler