Почему я не могу использовать std :: unomoromed_set :: Содержит с std :: mem_fn ?#include
#include
int main() {
std::mem_fn(&std::unordered_set::size); // Compiles
std::mem_fn(&std::unordered_set::contains); // Does not compile
}
< /code>
example.cpp: In function ‘int main()’:
example.cpp:6:14: error: no matching function for call to ‘mem_fn()’
6 | std::mem_fn(&std::unordered_set::contains); // Does not compile
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from example.cpp:1:
/nix/store/qdknxw57cwy1jkrhq7fzmiis73j42jv6-gcc-14.3.0/include/c++/14.3.0/functional:244:5: note: candidate: ‘template constexpr std::_Mem_fn std::mem_fn(_Tp _Class::*)’
244 | mem_fn(_Tp _Class::* __pm) noexcept
| ^~~~~~
/nix/store/qdknxw57cwy1jkrhq7fzmiis73j42jv6-gcc-14.3.0/include/c++/14.3.0/functional:244:5: note: template argument deduction/substitution failed:
example.cpp:6:14: note: couldn’t deduce template parameter ‘_Tp’
6 | std::mem_fn(&std::unordered_set::contains); // Does not compile
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Подробнее здесь: https://stackoverflow.com/questions/797 ... etcontains