Skip to content

Commit

Permalink
add comment regarding use of unary + operator
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffbrinkle committed Feb 5, 2024
1 parent 2aae3f2 commit 71ed45e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions au/io.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ namespace au {
// Streaming output support for Quantity types.
template <typename U, typename R>
std::ostream &operator<<(std::ostream &out, const Quantity<U, R> &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;
}
Expand Down

0 comments on commit 71ed45e

Please sign in to comment.