22. Literals of various temperature scales

To meet this requirement, we need to provide an implementation for several types, operators, and functions:

  • An enumeration of supported temperature scales called scale.
  • A class template to represent a temperature value, parameterized with the scale, called quantity.
  • Comparison operators ==, !=, <, >, <=, and >= that compare two quantities of the same time.
  • Arithmetic operators + and - that add and subtract values of the same quantity type. Additionally, we could implement member operators += and -+.
  • A function template to convert temperatures from one scale to another, called temperature_cast. This function does not perform the conversion itself but uses type traits to do that.
  • Literal operators ...

Get Modern C++: Efficient and Scalable Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.