2013-12-13 29 views
-2

最新的intel C++编译器是14.0.1.139或英特尔并行工作室xe 2013 sp1更新1.我想知道它是否支持隐式移动构造函数和移动赋值。我测试了下面的代码,它似乎没有工作。最新的intel C++编译器是否支持隐式移动构造函数和移动赋值?

相关文章是here(搜索移动构造函数)。它说它支持。但我无法做到。

#include <memory> 
#include <iostream> 
#include <algorithm> 

using namespace std; 

class A 
{ 
public: 
    unique_ptr<int> m; 
}; 

int main() 
{ 
    A a; 
    A b(std::move(a)); 
} 

编译它在Windows作为

icl main.cpp /Qstd=c++11 

错误

main.cpp 
main.cpp(10): error #373: "std::unique_ptr<_Ty, _Dx>::unique_ptr(const 
    std::unique_ptr<_Ty, _Dx>::_Myt &) [with _Ty=int, _Dx=std::default_delete<int>]" 
    (declared at line 1447 of "C:\Program Files (x86)\Microsoft Visual Studio 
    11.0\VC\include\memory") is inaccessible unique_ptr<int> m; 
                  ^
detected during implicit generation of "A::A(const A &)" at line 16 
compilation aborted for main.cpp (code 2) 

基本上在主函数A b(std::move(a));二号线正在寻找的拷贝构造函数A::A(const A &)少动构造A::A(const A &&)等。当没有隐式移动构造函数被生成时,这是通常的。但编译器表示它支持隐式移动构造函数。我很困惑。谢谢。

+1

你可以看看这里http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler – ForEveR

+1

相关文章是http://software.intel.com/en-us/articles/intel-composer-xe-2013-compilers-sp1-fixes-list。它表示支持。但我无法做到。 – user1899020

+0

“似乎不起作用”是什么意思? – juanchopanza

回答

2

答1:

在Windows环境中使用与2010年的Visual Studio的 英特尔C++编译器时,*或* 2012,采用Visual C支持C++ 11个++特性 2010/2012默认情况下启用。使用“/ Qstd = C++ 11”打开 支持所有其他情况。在Linux或Mac OS X环境中使用 “-std = C++ 11”。

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

答案2(猜测,因为缺乏信息): 如果设置了标志,则必须包括<algorithm>其中std::move定义。

回答3: 您的更新代码可以很好地编译GCC和Clang。也许你有明确定义的移动构造函数:

#include <memory> 
#include <iostream> 
#include <algorithm> 

using namespace std; 

class A 
{ 
public: 
    // default constructor 
    A() 
    {} 
    // move constructor 
    A(A&& rhs) 
    : m(std::move(rhs.m)) 
    {} 

    unique_ptr<int> m; 
}; 

int main() 
{ 
    A a; 
    A b(std::move(a)); 
} 
+0

我已经设置了这些选项。编译器仍然报告错误。 – user1899020

+0

我不知道,除非您编辑您的问题并添加此信息,否则其他任何人都不知道。另见我对你的问题的评论是什么错误信息。你的问题是没有用的,我会失望的。 – usr1234567

+0

包括。仍然报告错误。你有没有在英特尔C++中尝试它?任何操作系统都很好。我正在使用Windows。 – user1899020

相关问题