// lesson 2: numbers // // a digit is a syntax error. the only number literal is ::difference<'a', 'b'>, // the distance between two characters. 'F' - 'A' is 5. ::emit takes a type, and a // value is not a type, so wrap it in ::decltype(...) to make it one ::emit<::decltype(::difference<'F', 'A'>)>::commit; // arithmetic is ::sum, ::product and ::quotient. // no operators // no precedence // no problem ::emit< ::decltype( ::sum< ::difference<'F', 'A'>, ::difference<'C', 'A'> > ) >::commit; ::emit< ::decltype( ::product< ::difference<'D', 'A'>, ::difference<'E', 'A'> > ) >::commit; ::emit< ::decltype( ::quotient< ::difference<'H', 'A'>, ::difference<'C', 'A'> > ) >::commit; // ::integral_constant<::size_t, V>::value is V. it exists so you can write more // ::extent::value is the length of an array type, and 0 for anything else // this is the long way to write 20 ::emit< ::decltype( ::extent< ::array< ::byte, ::integral_constant< ::size_t, ::difference<'Z', 'F'> >::value > >::value ) >::commit; // emitting a type that is not a value prints the name of the type ::emit<::remove_cv_t<::int32_t>>::commit;