12 Mar
2017
12 Mar
'17
2:54 p.m.
John Maddock wrote:
5) What is the purpose of class safe_literal? constepxr initialization seems to work just fine without it?
The idea, I believe, is that if you have safe_signed_range<0, 100> x; and then you do auto y = x * safe_signed_literal<2>(); you get safe_signed_range<0, 200> as the type of y. This could probably be made less elaborate with a user-defined literal, for example auto y = x * 2_sf; or something like that. Since x is not constexpr, it's not possible (I think) to achieve this result without using a separate literal type to hold the compile-time constant 2.