From 71ed45ee584fc345775ccdd44770b584f4c1d1c7 Mon Sep 17 00:00:00 2001 From: Michael Hordijk Date: Mon, 5 Feb 2024 15:30:16 -0700 Subject: [PATCH] add comment regarding use of unary `+` operator --- au/io.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/au/io.hh b/au/io.hh index 26c8165c..f52464ff 100644 --- a/au/io.hh +++ b/au/io.hh @@ -25,6 +25,11 @@ namespace au { // Streaming output support for Quantity types. template std::ostream &operator<<(std::ostream &out, const Quantity &q) { + // In the case that the Rep is a type that resolves to 'char' (e.g. int8_t), + // the << operator will match the implementation that takes a character + // literal. Using the unary + operator will trigger an integer promotion on + // the operand, which will then match an appropriate << operator that will + // output the integer representation. out << +q.in(U{}) << " " << unit_label(U{}); return out; }