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 The Modern C++ Challenge now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.