Oh man.

supports a user-defined literal. So if you define an MyDistanceType operator""_km(long double val) function, it’ll allow you to say const auto distance = 12_km; and cause that to evaluate to a MyDistanceType representing 12 kilometers.

Cute, but I really can’t see why anyone would bother when the language already supports const auto distance = Distance::from_kilometers(12);

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.