I get very strange errors. The compiler seems to want to call the copy constructor for some reason, I don't understand.
(118) std::map<int, layer> xs; (119) xs.begin()->first;
layer
is not a copied, movable type.
class layer : public observable { layer(const layer&); layer& operator=(const layer&); public: layer(int index = -1); layer(layer&& other); layer& operator=(layer&& other);
For some reason, line 119 made the compiler try to call the copy constructor for std::pair
, why?
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(131): error C2248: 'layer::layer' : cannot access private member declared in class 'layer' 1> ..\layer.h(55) : see declaration of 'layer::layer' 1> ..\layer.h(53) : see declaration of 'layer' 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(129) : while compiling class template member function 'std::_Pair_base<_Ty1,_Ty2>::_Pair_base(const std::_Pair_base<_Ty1,_Ty2> &)' 1> with 1> [ 1> _Ty1=const int, 1> _Ty2=layer 1> ] 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility(174) : see reference to class template instantiation 'std::_Pair_base<_Ty1,_Ty2>' being compiled 1> with 1> [ 1> _Ty1=const int, 1> _Ty2=layer 1> ] 1> ..\stage.cpp(119) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled 1> with 1> [ 1> _Ty1=const int, 1> _Ty2=layer 1> ]
I also tried the following, where it fails.
(118) std::map<int, layer> xs; (119) auto& t1 = *xs.begin(); (120) auto& t2 = t1.first;
What's going on here?
ronag
source share