2014-04-09 4 views
0

나는 아래의 짧은 코드가 문제를 제공벡터 <unique_ptr>는

#include <memory> 
#include <vector> 
#include <tuple> 
using namespace std; 

struct A 
{ 
    A() {} 
    vector<unique_ptr<int>> m; 
    // Change the above line to "unique_ptr<int> m;" removes the compilation error 
    // Or add a line "A(A const&) = delete;" removes the compilation error also 
}; 

struct B 
{ 
    tuple<A> t; 
}; 

int main() 
{ 
    A a; 
    B b; 
    return 0; 
} 

VC2013 11 월 CTP 컴파일러 오류 제공 :

오류 1 오류 C2280 : '표준 :: unique_ptr> :: unique_ptr (CONST 표준을 :: unique_ptr < _Ty, 표준 : default_delete < _Ty >> &) ': 삭제 기능 xmemory0 593

이 컴파일러의 버그 또는 코드의 버그를 참조하려고?

+1

[여기 g ++로 작동합니다] (http://coliru.stacked-crooked.com/a/4427e08c08e83a19) –

+0

따라서 컴파일러 버그입니다. 감사. – user1899020

+0

복사 생성자를 삭제하는 이유는 무엇입니까? 당신이 그것을 사용하고 싶지 않다면 단지'비공개'로 만들 수 없을까요? 그리고이 오류는 복사 생성자가 트리거되고 있기 때문에 발생합니다. 나는 그것이 C++에서 당신에게 무엇인지 말해주기에 충분하지 않습니다. – Dan

답변

1

이것은 Visual Studio의 버그입니다. Gonmator의 코멘트 @를 따라가 VS2013  의로 업데이트   1. 고정 된 것

여기에는
https://connect.microsoft.com/VisualStudio/feedback/details/801826/std-tuple-with-rvalue-references-not-working-if-clr-enabled
또는
https://connect.microsoft.com/VisualStudio/feedback/details/891428/c-std-pair-has-no-default-move-constructor
으로보고 된 버그와 비슷한되었을 수 있습니다

- 관련된 분명히 MSVC가 있었다 여러 잔류 버그 "move semantics + std :: tuple".