diff --git a/include/date.hpp b/include/date.hpp index 7af27c1..159a14f 100644 --- a/include/date.hpp +++ b/include/date.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "cpp_utils/assert.hpp" @@ -582,4 +583,11 @@ struct hash { } }; +template <> +struct formatter : std::formatter { + auto format(budget::date p, format_context& ctx) const { + return formatter::format(date_to_string(p), ctx); + } +}; + } // end of namespace std diff --git a/include/money.hpp b/include/money.hpp index 3a2fcd6..3a10c1e 100644 --- a/include/money.hpp +++ b/include/money.hpp @@ -9,6 +9,7 @@ #include #include +#include #include "utils.hpp" @@ -230,3 +231,22 @@ inline std::string to_string(money amount){ } } //end of namespace budget + +namespace std { + +template <> +struct hash { + std::size_t operator()(budget::money d) const noexcept { + const std::hash hasher; + return hasher(d.value); + } +}; + +template <> +struct formatter : std::formatter { + auto format(budget::money p, format_context& ctx) const { + return formatter::format(money_to_string(p), ctx); + } +}; + +} // end of namespace std