From fe15572e906665e6ad41f4864b9f1c866d113874 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 8 Nov 2023 15:30:24 -1000 Subject: [PATCH] feat(example): unit symbols added to the currency example --- example/currency.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/example/currency.cpp b/example/currency.cpp index 40892ad2..613f1b6a 100644 --- a/example/currency.cpp +++ b/example/currency.cpp @@ -41,6 +41,15 @@ inline constexpr struct great_british_pound : named_unit<"GBP", kind_of> {} japanese_jen; // clang-format on +namespace unit_symbols { + +inline constexpr auto EUR = euro; +inline constexpr auto USD = us_dollar; +inline constexpr auto GBP = great_british_pound; +inline constexpr auto JPY = japanese_jen; + +} // namespace unit_symbols + static_assert(!std::equality_comparable_with, quantity>); @@ -88,7 +97,9 @@ quantity_point exchange_to(quantity_point q) int main() { - quantity_point price_usd = zero + 100 * us_dollar; + using namespace unit_symbols; + + quantity_point price_usd = zero + 100 * USD; quantity_point price_euro = exchange_to(price_usd); std::cout << price_usd.quantity_from(zero) << " -> " << price_euro.quantity_from(zero) << "\n";