fork download
  1. #include <map>
  2. #include <vector>
  3. #include <iostream>
  4.  
  5. int main() {
  6.  
  7. std::map<int *, std::vector<double>> m;
  8. const auto &cm = m;
  9. std::cout << cm[nullptr].size();
  10. }
Compilation error #stdin compilation error #stdout 0s 3464KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:9:25: error: passing 'const std::map<int*, std::vector<double> >' as 'this' argument discards qualifiers [-fpermissive]
  std::cout << cm[nullptr].size();
                         ^
In file included from /usr/include/c++/5/map:61:0,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_map.h:494:7: note:   in call to 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = int*; _Tp = std::vector<double>; _Compare = std::less<int*>; _Alloc = std::allocator<std::pair<int* const, std::vector<double> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<double>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = int*]'
       operator[](key_type&& __k)
       ^
stdout
Standard output is empty