vendredi 20 décembre 2019

unable to get key_type from a map

I wrote this piece of code, in order to find if a map contains a specific key.

template<typename T, typename... Args >
inline bool contains(const std::map<Args...>& map, const T& value) noexcept
{
  static_assert(std::is_constructible_v< decltype(map)::key_type , T >);

  return map.find(value) != std::end(map);
}

I have the following error :

error: 'key_type' is not a member of 'const std::map<std::__cxx11::basic_string<char>, Query>&'

What is the problem with decltype(map)::key_type ?

Aucun commentaire:

Enregistrer un commentaire