/
dinruspro
/
tutorial
Обзор
Документация
Войти
/
dinruspro
/
tutorial
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
CoreTutorial/CombineHash.cpp
35 строк
799 B
EnergonV
Уроки теперь тоже здесь!
09 янв 2024, 19:25
09 янв 2024, 19:25
4b3ebd6
Код
Авторство
О чём код?
#include "Tutorial.h" void CombineHashTutorial() { /// .CombineHash /// To simplify providing of high quality hash codes for composite types, U++ provides /// `CombineHash` utility class. This class uses `GetHashValue` function to gather hash /// codes of all values and combines them to provide final hash value for composite type: struct Foo { String a; int b; unsigned GetHashValue() const { return CombineHash(a, b); } }; /// Note that `GetHashValue` is defined as function template that calls `GetHashValue` /// method of its argument, therefore defining `GetHashValue` method defines `GetHashValue` /// function too: Foo x; x.a = "world"; x.b = 22; DUMP(GetHashValue(x)); /// x.a << '!'; DUMP(GetHashValue(x)); /// }