User-Defined Literals, Part 3 -- Andrzej Krzemieński
User-defined literals — Part III
In the previous post we have seen how we can define a raw literal operator template that enables us to convert almost any binary literal of the form
11011_b
to a corresponding value of typeunsigned int
at compile time and still use this value as a compile-time constant. However, the length of the literal has to be short enough to fit into the capacity of typeunsigned int
.In this post, as promised, we will try to make our literal render values of different types based on the length of the binary literal, so that
11011_b
renders value of typeunsigned int
and100010001000100010001000100010001000_b
renders value of typelong long unsigned int
...