fork download
  1. #include <iostream>
  2. #include <unordered_map>
  3.  
  4. int
  5. main()
  6. {
  7. const std::string key = "abc";
  8. std::unordered_map<std::string, int> map;
  9. map[key] = 123;
  10. std::cout << map[key] << std::endl;
  11. std::cout << *(map + key) << std::endl;
  12. return 0;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:11:21: error: no match for 'operator+' (operand types are 'std::unordered_map<std::basic_string<char>, int>' and 'const string {aka const std::basic_string<char>}')
  std::cout << *(map + key) << std::endl;
                     ^
prog.cpp:11:21: note: candidates are:
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2491:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, _CharT)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2491:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2485:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2485:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2479:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(_CharT __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2479:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   types 'std::basic_string<_CharT, _Traits, _Alloc>' and 'const string {aka const std::basic_string<char>}' have incompatible cv-qualifiers
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2473:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(const _CharT* __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2473:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   mismatched types 'const _CharT*' and 'std::unordered_map<std::basic_string<char>, int>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2461:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2461:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2455:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>&&)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2455:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2449:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(std::basic_string<_CharT, _Traits, _Alloc>&&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2449:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2437:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, _CharT)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
     ^
/usr/include/c++/4.9/bits/basic_string.h:2437:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2421:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2421:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:53:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.tcc:708:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
     ^
/usr/include/c++/4.9/bits/basic_string.tcc:708:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   deduced conflicting types for parameter '_CharT' ('std::unordered_map<std::basic_string<char>, int>' and 'char')
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:53:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.tcc:692:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(const _CharT* __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.tcc:692:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   mismatched types 'const _CharT*' and 'std::unordered_map<std::basic_string<char>, int>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:2384:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
     ^
/usr/include/c++/4.9/bits/basic_string.h:2384:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'std::unordered_map<std::basic_string<char>, int>' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.9/bits/char_traits.h:39,
                 from /usr/include/c++/4.9/ios:40,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_iterator.h:1135:5: note: template<class _Iterator> std::move_iterator<_Iterator> std::operator+(typename std::move_iterator<_Iterator>::difference_type, const std::move_iterator<_Iterator>&)
     operator+(typename move_iterator<_Iterator>::difference_type __n,
     ^
/usr/include/c++/4.9/bits/stl_iterator.h:1135:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'const string {aka const std::basic_string<char>}' is not derived from 'const std::move_iterator<_Iterator>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.9/bits/char_traits.h:39,
                 from /usr/include/c++/4.9/ios:40,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_iterator.h:334:5: note: template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)
     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
     ^
/usr/include/c++/4.9/bits/stl_iterator.h:334:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'const string {aka const std::basic_string<char>}' is not derived from 'const std::reverse_iterator<_Iterator>'
  std::cout << *(map + key) << std::endl;
                       ^
In file included from /usr/include/c++/4.9/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.9/bits/char_traits.h:39,
                 from /usr/include/c++/4.9/ios:40,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/stl_iterator.h:918:5: note: template<class _Iterator, class _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::operator+(typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
     operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
     ^
/usr/include/c++/4.9/bits/stl_iterator.h:918:5: note:   template argument deduction/substitution failed:
prog.cpp:11:23: note:   'const string {aka const std::basic_string<char>}' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
  std::cout << *(map + key) << std::endl;
                       ^
stdout
Standard output is empty