C++: Difference between revisions

309 bytes added ,  7 January 2020
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==