这个坑其实我早就知道,只不过是没有这个数据就会自动创建而已,顶多是一些错误数据而已,今天竟然出现了编译错误!!!我特么还以为是构造函数的问题,查了一小时。我平时map用的很少,都是unordered_map,但是如果数据量小,哈希的效率还没有红黑树高,我就换了map,开始的时候看到源码中用的中括号,我就用了,也过了,就没当回事,后来自己大改,编译错误就出现了。
报的这个错误
In instantiation of ‘std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>) [with _Args1 = {const int&}; unsigned int ..._Indexes1 = {0u}; _Args2 = {}; unsigned int ..._Indexes2 = {}; _T1 = const int; _T2 = thread_graphic]’:
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/tuple:1575:63: required from ‘std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>) [with _Args1 = {const int&}; _Args2 = {}; _T1 = const int; _T2 = thread_graphic]’
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/ext/new_allocator.h:120:4: required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<const int, thread_graphic>; _Args = {const std::piecewise_construct_t&, std::tuple<const int&>, std::tuple<>}; _Tp = std::_Rb_tree_node<std::pair<const int, thread_graphic> >]’
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/bits/alloc_traits.h:455:4: required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<const int, thread_graphic>; _Args = {const std::piecewise_construct_t&, std::tuple<const int&>, std::tuple<>}; _Tp = std::_Rb_tree_node<std::pair<const int, thread_graphic> >; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::_Rb_tree_node<std::pair<const int, thread_graphic> > >]’
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/bits/stl_tree.h:543:32: required from ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const int&>, std::tuple<>}; _Key = int; _Val = std::pair<const int, thread_graphic>; _KeyOfValue = std::_Select1st<std::pair<const int, thread_graphic> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, thread_graphic> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const int, thread_graphic> >*]’
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/bits/stl_tree.h:560:4: required from ‘std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const int&>, std::tuple<>}; _Key = int; _Val = std::pair<const int, thread_graphic>; _KeyOfValue = std::_Select1st<std::pair<const int, thread_graphic> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, thread_graphic> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const int, thread_graphic> >*]’
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/bits/stl_tree.h:2196:64: required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const int&>, std::tuple<>}; _Key = int; _Val = std::pair<const int, thread_graphic>; _KeyOfValue = std::_Select1st<std::pair<const int, thread_graphic> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, thread_graphic> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const int, thread_graphic> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<const int, thread_graphic> >]’
/opt/hisi-linux/x86-arm/arm-himix200-linux/arm-linux-gnueabi/include/c++/6.3.0/bits/stl_map.h:483:8: required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = int; _Tp = thread_graphic; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, thread_graphic> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = thread_graphic; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int]’
我特喵啥也看不懂,结果后来用了find和insert,一下就好了,具体原因没深究,估计要看一下源码才知道了,这个问题先记下吧