9 template<typename item_t
, typename iter_t
>
10 void CoutEachItem(iter_t begin
, iter_t end
, const string
& space
= "\n")
12 std::copy(begin
, end
, std::ostream_iterator
<item_t
>(cout
, space
.c_str()));
17 vector
<string
> tokens
;
18 string sentence
= "something a like you? ...";
19 istringstream
iss(sentence
);
21 copy(istream_iterator
<string
>(iss
),
22 istream_iterator
<string
>(),
23 back_inserter
<vector
<string
> >(tokens
));
25 CoutEachItem
<string
>(tokens
.begin(), tokens
.end(), "|");
27 copy(istream_iterator<string>(iss),
28 istream_iterator<string>(),
29 ostream_iterator<string>(cout, "\n"));