
The problem with this approach is that equality of keys can't be more general than type identity.
Instead a special "hash"-like function could be provided that would transform the keys to a type where identity could be used. This might be faster
using linear/binary search, since the the compiler can do the lookup
than based
on identity. « []
I have thought about that already, but how would you define such a hash function for _heterogeneous_ objects?
Its not a real hash function. It just would return an object(ie type) where
identity(ie `std::is_same`) can be used. That is it will apply the function
as
a transform to the key, and use the result to lookup the key using name
lookup. It could default to being identity:
auto m = make_hash_map(
identity,
make_pair(type<T>, x),
make_pair(type<U>, y)
);
assert(m[type<T>] == x);
However, if the user wants store intregral constants, and wants it to work
with any integral constant, then a custom "hash" function could be used,
which
would convert every integral constant of the same value to the same type:
auto hash_intregral_constant = [](auto x) ->
integral_constant