Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / range / doc / reference / adaptors / examples / tokenized.cpp
1 // Boost.Range library
2 //
3 //  Copyright Thorsten Ottosen 2003-2004. Use, modification and
4 //  distribution is subject to the Boost Software License, Version
5 //  1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // For more information, see http://www.boost.org/libs/range/
9 //
10 #include <boost/range/adaptor/tokenized.hpp>
11 #include <boost/range/algorithm_ext/push_back.hpp>
12 #include <boost/assert.hpp>
13 #include <algorithm>
14 #include <string>
15 #include <vector>
16
17 int main(int argc, const char* argv[])
18 {
19     using namespace boost::adaptors;
20     
21     std::string input = " a b c d e f g hijklmnopqrstuvwxyz";
22     std::vector< boost::sub_match< std::string::iterator > > result;
23     boost::push_back(result, input | tokenized(boost::regex("\\b")));
24     
25     BOOST_ASSERT( boost::size(result) == 16u );
26     
27     return 0;
28 }