xte ::literal ::analog {}
Defined in header <xte/literal/analog.hpp> Allows expressing integers visually as lines, rectangles, and rectangular prisms.
Inspired by http://eelis.net/C++/analogliterals.xhtml.
Definition
The length of each side of a shape is determined by the number of connecting characters between its vertices, not counting characters representing vertices.namespace literal ::analog {inline constexpr struct {static constexpr xte ::uz width =/* ... */ ;static constexpr xte ::uz height =/* ... */ ;static constexpr xte ::uz length =/* ... */ ;static constexpr xte ::uz area =/* ... */ ;static constexpr xte ::uz volume =/* ... */ ;// ... }x ; }
Lines set
length , rectangles set width and height , and rectangular prisms set width , height , and length .Rectangles set
area to width * height , and rectangular prisms set area to the sum of the areas of all six sides.Rectangular prisms set
volume to width * height * length .Examples
#0[View in Compiler Explorer]using namespace xte ::literal ::analog ;static_assert ((x - - -x ).length ==3 );
#1
[View in Compiler Explorer]using namespace xte ::literal ::analog ;static_assert ((x - - - + ! ! ! ! ! ! + - - -x ).area ==9 );
#2
[View in Compiler Explorer]using namespace xte ::literal ::analog ;static_assert ((x - - - + !* * ! * * ! * * + + - - - + * ! ! * ! ! *! ! + - - -x ).volume ==27 );