The latest intel C++ compiler is 14.0.1.139 or in intel parallel studio xe 2013 sp1 update 1. I am wondering if it supports implicit move constructor and move assignment. I tested it the following code, it doesn't seem to work.
The related article is here (search move constructor). It said it supports. But I cannot make it.
#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));
}
Compile it on windows as
icl main.cpp /Qstd=c++11
Errors
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)
Basically the 2nd line in the main function A b(std::move(a));
is looking for copy constructor A::A(const A &)
other than move constructor A::A(const A &&)
. That is usual when no implicit move constructors are generated. But the compiler said it support implicit move constructor. I am confused. Thanks.
Answer 1:
From http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler
Answer 2 (guessing because of lack of information): If the flag is set, you must include
<algorithm>
wherestd::move
is defined.Answer 3: Your updated code compiles well with GCC and Clang. Maybe you have to define the move constructor explicitly: