Здравствуйте, B0FEE664, Вы писали:
BFE>Можно ли используя structured bindings написать шаблонную универсальную хэш-функцию для std::unordered_map при условияя, что для каждого из полей структуры есть (стандартная) хэш функция?
Можно.
Стандартной нет.
Есть boost::pfr::hash
https://www.boost.org/doc/libs/1_87_0/doc/html/reference_section_of_pfr.html#doxygen.reference_section_of_pfr.functors_8hpp
https://www.boost.org/doc/libs/1_87_0/doc/html/doxygen/reference_section_of_pfr/structboost_1_1pfr_1_1hash.html
#include <boost/pfr/functors.hpp>
struct my_struct { // No operators defined for that structure
int i; short s; char data[7]; bool bl; int a,b,c,d,e,f;
};
// ...
std::unordered_set<
my_struct,
boost::pfr::hash<my_struct>,
boost::pfr::equal_to<my_struct>
> my_set;