Am 02.10.2023 um 19:35 schrieb Aaron Gray:
> Thanks for pointing that out !
Maybe that should be the final solution:
template<>
struct hash<pair<Type*, Type*>>
{
size_t operator ()(pair<Type*, Type*> const& key)
{
size_t h = 0;
std::hash<string_view> hsv;
auto extend = [&]( auto, Type *pT ) { h ^= hsv( pT ?
string_view( pT->name.begin(), pT->name.end() ) : string_view( "" ) ); };
extend( false_type(), key.first );
extend( true_type(), key.second );
return h;
}
};
I use lambdas to save code. To force them to be inlined I make
them generic and call each instntiation only once. To instantiate
the lambda above twice I call them with different bool_constant<X>
types.