template<typename S>
struct appender
{
private:
S &buffer_;
public:
explicit appender(S &buffer) : buffer_(buffer) { }
template<typename Res, typename T1, typename T2>
void operator()(addition<Res, T1, T2> const &app) const
{
(*this)(app.first());
(*this)(app.second());
}
void operator()(S const &data) const
{ buffer_ += data; }
void operator()(typename S::value_type const &data) const
{ buffer_ += data; }
};