0
cppreference.com에 따르면 다음 코드가 컴파일되어 작동해야합니다. 저장된 포인터가 ap.release()
으로 초기화되고 저장된 deleter가 값으로 초기화되는 unique_ptr
을 생성해야합니다. 나는 그것을 컴파일하면std :: auto_ptr에서 std :: unique_ptr 변환 생성자
#include <memory>
int main()
{
std::auto_ptr<int> ap(new int());
std::unique_ptr<int> up(std::move(ap));
}
합니다 (VS2010 도구 세트와 VS2013를 사용하여) 나는 다음과 같은 오류 얻을 :
test.cpp(5): error C2664: 'std::unique_ptr<_Ty>::unique_ptr(std::nullptr_t)' :
cannot convert parameter 1 from 'std::auto_ptr<_Ty>' to 'std::nullptr_t'
with
[
_Ty=int
]
nullptr can only be converted to pointer or handle types
이는 VS2010 도구 세트에 대한 컴파일러의 버그인가?
[GCC와 잘 동작합니다.] (http://ideone.com/LWj8P9) –
버그가 될 것으로 보입니다. VC 2010에서와 같은 오류가 발생하지만 VC 2012에서 제대로 작동합니다. – ComicSansMS
@ComicSansMS : 사용자 의견이 대답 인 경우이 질문에 대한 대답으로 받아 들일 것입니다. – dalle