#include #include template struct Quantity { double value; explicit constexpr Quantity(double v) : value(v) {} }; template constexpr Quantity operator+(Quantity a, Quantity b) { return Quantity{a.value + b.value}; } template constexpr Quantity operator*( Quantity a, Quantity b) { return Quantity{a.value * b.value}; } template concept Addable = requires(A a, B b) { a + b; }; using Length = Quantity<1, 0>; using Duration = Quantity<0, 1>; using Speed = Quantity<1, -1>; static_assert(Addable); static_assert(!Addable); static_assert(std::same_as); int main() { const Speed speed{3}; const Duration elapsed{4}; const Length traveled = speed * elapsed; const auto total = traveled + Length{5}; assert(traveled.value == 12); assert(total.value == 17); }