//try8.cpp
#include <utility>
#include <unordered_map>
#include <algorithm>
std::unordered_map<int, std::string> m_foo;
int main() {
using value = std::unordered_map<int, std::string>::value_type;
std::remove_if(m_foo.begin(), m_foo.end(), [](value& v){
return v.first < 3;
});
return 0;
}
g++ ./try8.cpp gave me:
/usr/include/c++/7/bits/stl_algo.h:871:16: error: use of deleted function ‘std::pair<const int, std::__cxx11::basic_string<char> >& std::pair<const int, std::__cxx11::basic_string<char> >::operator=(const std::pair<const int, std::__cxx11::basic_string<char> >&)’
*__result = _GLIBCXX_MOVE(*__first);
^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/string:40,
from ./try8.cpp:1:
/usr/include/c++/7/bits/stl_pair.h:208:12: note: ‘std::pair<const int, std::__cxx11::basic_string<char> >& std::pair<const int, std::__cxx11::basic_string<char> >::operator=(const std::pair<const int, std::__cxx11::basic_string<char> >&)’ is implicitly declared as deleted because ‘std::pair<const int, std::__cxx11::basic_string<char> >’ declares a move constructor or move assignment operator
struct pair
Can anybody explain this to me? Thanks!
Why did my std::pair<int, std::string>
pair become std::pair<*const* int, std::string>
?