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

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;
}
The length of each side of a shape is determined by the number of connecting characters between its vertices, not counting characters representing vertices.
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
using namespace xte::literal::analog;

static_assert((x - - - x).length == 3);
[View in Compiler Explorer]

#1
using namespace xte::literal::analog;

static_assert((x - - - +
               !       !
               !       !
               !       !
               + - - - x).area == 9);
[View in Compiler Explorer]

#2
using namespace xte::literal::analog;

static_assert((x - - - +
               !*       *
               ! *       *
               !  *       *
               +   + - - - +
                *  !       !
                 * !       !
                  *!       !
                   + - - - x).volume == 27);
[View in Compiler Explorer]