Created
May 27, 2018 10:34
-
-
Save loganek/2692742098dad0cd3dceb0fb43406ddb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Font | |
{ | |
std::string name; | |
uint16_t size; | |
bool is_bold; | |
bool is_italic; | |
}; | |
bool operator==(const Font& f1, const Font& f2) | |
{ | |
return | |
f1.name == f2.name && | |
f1.size == f2.size && | |
f1.is_bold == f2.is_bold && | |
f1.is_italic == f2.is_italic; | |
} | |
uint32_t djb2(const std::string& text) { return 0 /* TODO */; } | |
namespace std { | |
template <> | |
struct hash<Font> | |
{ | |
std::size_t operator()(const Font& font) const | |
{ | |
int64_t hash = djb2(font.name); | |
hash |= (static_cast<uint64_t>(font.size) << 32); | |
hash |= (static_cast<uint64_t>(font.is_bold)) << 48; | |
hash |= (static_cast<uint64_t>(font.is_bold)) << 56; | |
return static_cast<std::size_t>(hash); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment