10_x;
This is not entirely correct. The list of template options is not empty. When you write:
template <char... Cs> ??? operator "" _x()
Cs filled from the material on the left side of the literal. That is, when you write:
10_x
which causes:
operator ""_x<'1', '0'>();
One simple example is to build compilation time overflowing a binary literal so that:
template <uint64_t V> constexpr uint64_t make_binary() { return V; } template <uint64_t V, char C, char... Cs> constexpr uint64_t make_binary() { static_assert(C == '0' || C == '1', "invalid binary"); return make_binary<2*V + C - '0', Cs...>(); } template <char... Cs> uint64_t operator "" _b() { static_assert(sizeof...(Cs) <= 64, "overflow"); return make_binary<0, Cs...>(); } uint64_t a = 101_b;
Barry
source share