CodeTheRobot

C++ Advanced · exercise 04

Compile-time unit safety

Make a wrong unit a compile error and keep the maths constexpr.

C++ Advanced lesson 04

Guided steps

  1. 1.Give Radians a constexpr constructor and a constexpr addition that only accepts Radians.
  2. 2.Prove the result at compile time with static_assert.
  3. 3.Print the runtime value of the same constant.

Your code

Your code is saved in this browser after every run and restored next time.