#ifndef OPERATORS_HPP_ #define OPERATORS_HPP_ #include "number.hpp" #include "white.hpp" struct multiplication; typedef concat < white , number , opt < concat < white , terminal< '*' > , white , multiplication > > , white > mult_impl; struct multiplication : mult_impl { template< class ...ArgTypes > constexpr multiplication( ArgTypes ...args ) : mult_impl( args... ) { } constexpr unsigned int eval() { return get< 1 >().eval() * ( get< 2 >() ? get< 2 >().get().get< 3 >().eval() : 1 ); } }; struct addition; typedef concat < white , multiplication , opt < concat < white , terminal< '+' > , white , addition > > , white > addit_impl; struct addition : addit_impl { template< class ...ArgTypes > constexpr addition( ArgTypes ...args ) : addit_impl( args... ) { } constexpr unsigned int eval() { return get< 1 >().eval() + ( get< 2 >() ? get< 2 >().get().get< 3 >().eval() : 0 ); } }; #endif