के वेक्टर वाले ऑब्जेक्ट्स की एक सूची को सॉर्ट करना निम्नलिखित कोड को C++ 11 (यदि ऐसा है?) के अनुसार संकलन त्रुटि उत्पन्न करना है या यह VC11 के साथ कोई समस्या है?अद्वितीय_ptr
#include <vector>
#include <list>
#include <memory>
struct A
{
std::vector<std::unique_ptr<int>> v;
};
int main()
{
std::list<A> l;
l.sort([](const A& a1, const A& a2){ return true; });
}
विजुअल C++ 2012 निम्नलिखित संकलन त्रुटि पैदा करता है:
1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(606): error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>'
1> with
1> [
1> _Ty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\memory(1447) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr'
1> with
1> [
1> _Ty=int
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(605) : while compiling class template member function 'void std::allocator<_Ty>::construct(_Ty *,const _Ty &)'
1> with
1> [
1> _Ty=std::unique_ptr<int>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0(751) : see reference to function template instantiation 'void std::allocator<_Ty>::construct(_Ty *,const _Ty &)' being compiled
1> with
1> [
1> _Ty=std::unique_ptr<int>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\type_traits(743) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
1> with
1> [
1> _Ty=std::unique_ptr<int>
1> ]
1> c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector(655) : see reference to class template instantiation 'std::is_empty<_Ty>' being compiled
1> with
1> [
1> _Ty=std::allocator<std::unique_ptr<int>>
1> ]
1> d:\test2\test2.cpp(213) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=std::unique_ptr<int>
1> ]
संदर्भ के लिए, मैं क्लैंग और जीसीसी में इसे ठीक से संकलित कर सकता हूं। तो यह या तो आपका कंपाइलर या आपकी सेटिंग्स है। – chrisaycock
@chrisaycock ओह ठीक है, माइक्रोसॉफ्ट कनेक्ट पर एक और वीसी 11 बग रिपोर्ट बनाने जा रहा है ... – PowerGamer
मैं इसे पूरी तरह से छोड़ दूंगा। –