I'm writing a C++ concept for unordered associative containers namely std::unordered_map. I'm having difficulty detecting the erase function (also insert but lets ignore that for the moment).
Here's my concept attempt, sadly it fails when I try calling a templated function requiring it.
template <class _ContainerType_>
concept InsertErasable = requires(_ContainerType_ a)
{
{ a.erase( _ContainerType_::const_iterator) } -> typename _ContainerType_::iterator;
};
I use it like so:
template<InsertErasable _ContainerType_>
inline void Test123( const _ContainerType_& container )
{
return;
}
std::unordered_map<std::string, int> map;
::Test123(map);
error C7602: 'Test123': the associated constraints are not satisfied
Using latest Visual Studio 2019.
It should detect the first erase signature shown here: https://en.cppreference.com/w/cpp/container/unordered_map/erase
Any idea what I am doing wrong?