mardi 26 septembre 2017

g++ compiler error on deleted assignment operator of pair

I think the following reduced C++11 code should be valid.

unordered_map<string,string> test;
auto it = remove_if( test.begin(), test.end(),
    [] (const decltype(test)::value_type &entry) { return true; } );

But it fails to compile with g++ 6.3, complaining about a deleted assignment operator of std::pair, but AFAIK that operator is not deleted.

/usr/include/c++/6/bits/stl_algo.h:868:16: error: use of deleted function ‘std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=( ...
*__result = _GLIBCXX_MOVE(*__first);

Is this a compiler/glibc bug or is the code really invalid for some reason I fail to see?

Aucun commentaire:

Enregistrer un commentaire