diff --git a/fun_out_iter_example.cpp b/fun_out_iter_example.cpp index dc84d39..ff3e0a2 100644 --- a/fun_out_iter_example.cpp +++ b/fun_out_iter_example.cpp @@ -15,12 +15,18 @@ #include -struct string_appender { - string_appender(std::string& s) : m_str(s) { } - void operator()(const std::string& x) const { - m_str += x; - } - std::string& m_str; +struct string_appender +{ + string_appender(std::string& s) + : m_str(&s) + {} + + void operator()(const std::string& x) const + { + *m_str += x; + } + + std::string* m_str; }; int main(int, char*[])