mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-06-25 22:45:18 -04:00
40 lines
751 B
ReStructuredText
40 lines
751 B
ReStructuredText
|
.. Copyright David Abrahams 2006. Distributed under the Boost
|
||
|
.. Software License, Version 1.0. (See accompanying
|
||
|
.. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||
|
|
||
|
Example
|
||
|
.......
|
||
|
|
||
|
::
|
||
|
|
||
|
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*[])
|
||
|
{
|
||
|
std::vector<std::string> x;
|
||
|
x.push_back("hello");
|
||
|
x.push_back(" ");
|
||
|
x.push_back("world");
|
||
|
x.push_back("!");
|
||
|
|
||
|
std::string s = "";
|
||
|
std::copy(x.begin(), x.end(),
|
||
|
boost::make_function_output_iterator(string_appender(s)));
|
||
|
|
||
|
std::cout << s << std::endl;
|
||
|
|
||
|
return 0;
|
||
|
}
|