5,321
edits
(→String) |
|||
Line 356: | Line 356: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
====std::unordered_map==== | ====std::unordered_map==== | ||
;Custom Keys | |||
How to use a rational number as a key in C++ | |||
<syntaxhighlight lang="C++"> | |||
struct Fraction | |||
{ | |||
int num; | |||
int den; | |||
bool operator==(const Fraction &other) const { | |||
return num*other.den == den * other.num; | |||
} | |||
Fraction(int a, int b) : num(a), den(b) {} | |||
}; | |||
</syntaxhighlight> | |||
==Boost== | ==Boost== |