fork(1) download
  1. #include <iostream>
  2. #include <unordered_map>
  3. #include <algorithm>
  4.  
  5. int main() {
  6. std::unordered_map<int, int> uom = { { 0, 10 }, { 1, 11 }, { 2, 12 } };
  7. auto fit = std::remove_if(uom.begin(), uom.end(),
  8. [](const std::pair<int, int>& values) { return values.first == 1; });
  9. for (auto& values : uom) {
  10. std::cout << values.first << ' ' << values.second << '\n';
  11. }
  12. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h: In instantiation of 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(std::pair<_T1, _T2>&&) [with _T1 = const int; _T2 = int]':
/usr/include/c++/5/bits/stl_algo.h:868:23:   required from '_ForwardIterator std::__remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = std::__detail::_Node_iterator<std::pair<const int, int>, false, false>; _Predicate = __gnu_cxx::__ops::_Iter_pred<main()::<lambda(const std::pair<int, int>&)> >]'
/usr/include/c++/5/bits/stl_algo.h:936:30:   required from '_FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = std::__detail::_Node_iterator<std::pair<const int, int>, false, false>; _Predicate = main()::<lambda(const std::pair<int, int>&)>]'
prog.cpp:8:70:   required from here
/usr/include/c++/5/bits/stl_pair.h:170:8: error: assignment of read-only member 'std::pair<const int, int>::first'
  first = std::forward<first_type>(__p.first);
        ^
stdout
Standard output is empty