#include #include /* unchanged from et/1_first_draft.cpp */ struct Add { template static auto eval(T lhs, T rhs) { return lhs + rhs; } }; struct Mul { template static auto eval(T lhs, T rhs) { return lhs * rhs; } }; template class Value { T _value; public: Value(T value): _value(value) {} auto eval() const { return _value; } }; /* end of unchanged */ template class Expr { std::tuple _operands; public: Expr(Operands... operands): _operands{operands...} {} auto eval() const { return eval(std::make_index_sequence{}); } private: template auto eval(std::index_sequence) const { return Op::eval(std::get(_operands).eval()...); } }; /* unchanged from et/1_first_draft.cpp */ int main() { using SubExpr = Expr, Value>; using MyExpr = Expr, SubExpr>; int volatile v0 = 3, v1 = 5, v2 = 7; int result; MyExpr expr{{v0}, {{v1}, {v2}}}; result = expr.eval(); std::printf("%d\n", result); } /* end of unchanged */