// lesson 4: conditions // // a condition is ::true_type::value, ::false_type::value, ::equal::value, // ::less::value, or ::is_same::value. the ::value is mandatory // a condition without it is a type, and a type is not a condition. // ::conditional_t picks a type. this prints 1 ::emit< ::conditional_t< ::true_type::value, ::decltype(::difference<'B', 'A'>), ::void > >::commit; // this picks ::void, and emitting ::void prints nothing at all. not even a newline ::emit< ::conditional_t< ::less< ::difference<'B', 'A'>, ::difference<'A', 'A'> >::value, ::decltype(::difference<'Z', 'A'>), ::void > >::commit; // ::enable_if_t> runs the statements when C holds // the statements inside a sequence are separated by commas, and each one is // still committed on its own ::enable_if_t< ::is_same< ::remove_cv_t<::int32_t>, ::int32_t >::value, ::sequence< ::emit< ::tuple< ::integral_constant<::char, ::difference<'s', '\0'>>, ::integral_constant<::char, ::difference<'a', '\0'>>, ::integral_constant<::char, ::difference<'m', '\0'>>, ::integral_constant<::char, ::difference<'e', '\0'>> > >::commit > >::commit; // ::static_assert stops the program when C does not hold. it does this at // runtime, because that is when we know ::static_assert< ::equal< ::difference<'C', 'A'>, ::sum< ::difference<'B', 'A'>, ::difference<'B', 'A'> > >::value >::commit; // ::conditional is the same idea for values. this prints 9 ::emit< ::decltype( ::conditional< ::false_type::value, ::difference<'A', 'A'>, ::difference<'J', 'A'> > ) >::commit;