month_hash
month_hash (month 해시 지원)
std::hash<std::chrono::month> 특수화가 std::chrono::month 타입에 대한 해시를 제공해요. <chrono> 헤더에 정의되어 있어요.
출처: cppreference
본문
std::chrono::month는 std::hash 특수화를 통해 해시할 수 있어요. std::hash<std::chrono::month>는 std::chrono::month 값을 기반으로 해시를 계산해요.
template<>
struct std::hash<std::chrono::month>;
이 특수화는 std::chrono::month를 해시 기반 컨테이너의 키로 사용할 수 있게 해줘요.
예제 (Example)
#include <chrono>
#include <iostream>
#include <unordered_set>
int main()
{
std::unordered_set<std::chrono::month> months;
months.insert(std::chrono::month{7});
std::cout << months.size() << '\n'; // 1
}