|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82345 - in trunk/libs/range: doc/html doc/html/range/reference/adaptors/reference doc/reference/adaptors doc/reference/adaptors/examples test test/adaptor_test
From: zeratul976_at_[hidden]
Date: 2013-01-03 19:58:17
Author: nathanridge
Date: 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
New Revision: 82345
URL: http://svn.boost.org/trac/boost/changeset/82345
Log:
[range] fixed #7843 (missing example in docs for 'tokenized' range adaptor)
Added:
trunk/libs/range/test/adaptor_test/tokenized_example.cpp (contents, props changed)
Removed:
trunk/libs/range/doc/reference/adaptors/examples/tokenized.cpp
Text files modified:
trunk/libs/range/doc/html/index.html | 2
trunk/libs/range/doc/html/range/reference/adaptors/reference/tokenized.html | 45 ++++++++++++++++++++++++++++++++++++++++
trunk/libs/range/doc/reference/adaptors/tokenized.qbk | 18 ++++++++++++++++
trunk/libs/range/test/Jamfile.v2 | 4 +-
4 files changed, 66 insertions(+), 3 deletions(-)
Modified: trunk/libs/range/doc/html/index.html
==============================================================================
--- trunk/libs/range/doc/html/index.html (original)
+++ trunk/libs/range/doc/html/index.html 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
@@ -147,7 +147,7 @@
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: January 03, 2013 at 23:22:09 GMT</small></p></td>
+<td align="left"><p><small>Last revised: January 04, 2013 at 00:56:46 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: trunk/libs/range/doc/html/range/reference/adaptors/reference/tokenized.html
==============================================================================
--- trunk/libs/range/doc/html/range/reference/adaptors/reference/tokenized.html (original)
+++ trunk/libs/range/doc/html/range/reference/adaptors/reference/tokenized.html 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
@@ -26,6 +26,7 @@
<div class="titlepage"><div><div><h5 class="title">
<a name="range.reference.adaptors.reference.tokenized"></a><a class="link" href="tokenized.html" title="tokenized">tokenized</a>
</h5></div></div></div>
+<div class="toc"><dl><dt><span class="section">tokenized_example</span></dt></dl></div>
<div class="informaltable"><table class="table">
<colgroup>
<col>
@@ -134,6 +135,50 @@
Access Range</a>
</li>
</ul></div>
+<div class="section range_reference_adaptors_reference_tokenized_tokenized_example">
+<div class="titlepage"><div><div><h6 class="title">
+<a name="range.reference.adaptors.reference.tokenized.tokenized_example"></a><a class="link" href="tokenized.html#range.reference.adaptors.reference.tokenized.tokenized_example" title="tokenized_example">tokenized_example</a>
+</h6></div></div></div>
+<p>
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">adaptor</span><span class="special">/</span><span class="identifier">tokenized</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">copy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">assign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">argc</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">argv</span><span class="special">[])</span>
+<span class="special">{</span>
+ <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">adaptors</span><span class="special">;</span>
+
+ <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sub_match</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">></span> <span class="identifier">match_type</span><span class="special">;</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">input</span> <span class="special">=</span> <span class="string">" a b c d e f g hijklmnopqrstuvwxyz"</span><span class="special">;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">copy</span><span class="special">(</span>
+ <span class="identifier">input</span> <span class="special">|</span> <span class="identifier">tokenized</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex</span><span class="special">(</span><span class="string">"\\w+"</span><span class="special">)),</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream_iterator</span><span class="special"><</span><span class="identifier">match_type</span><span class="special">>(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">,</span> <span class="string">"\n"</span><span class="special">));</span>
+
+ <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+<p>
+ This would produce the output:
+</p>
+<pre class="programlisting"><span class="identifier">a</span>
+<span class="identifier">b</span>
+<span class="identifier">c</span>
+<span class="identifier">d</span>
+<span class="identifier">e</span>
+<span class="identifier">f</span>
+<span class="identifier">g</span>
+<span class="identifier">hijklmnopqrstuvwxyz</span>
+</pre>
+<p>
+ </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Deleted: trunk/libs/range/doc/reference/adaptors/examples/tokenized.cpp
==============================================================================
--- trunk/libs/range/doc/reference/adaptors/examples/tokenized.cpp 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
+++ (empty file)
@@ -1,28 +0,0 @@
-// Boost.Range library
-//
-// Copyright Thorsten Ottosen 2003-2004. Use, modification and
-// distribution is subject to 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)
-//
-// For more information, see http://www.boost.org/libs/range/
-//
-#include <boost/range/adaptor/tokenized.hpp>
-#include <boost/range/algorithm_ext/push_back.hpp>
-#include <boost/assert.hpp>
-#include <algorithm>
-#include <string>
-#include <vector>
-
-int main(int argc, const char* argv[])
-{
- using namespace boost::adaptors;
-
- std::string input = " a b c d e f g hijklmnopqrstuvwxyz";
- std::vector< boost::sub_match< std::string::iterator > > result;
- boost::push_back(result, input | tokenized(boost::regex("\\b")));
-
- BOOST_ASSERT( boost::size(result) == 16u );
-
- return 0;
-}
Modified: trunk/libs/range/doc/reference/adaptors/tokenized.qbk
==============================================================================
--- trunk/libs/range/doc/reference/adaptors/tokenized.qbk (original)
+++ trunk/libs/range/doc/reference/adaptors/tokenized.qbk 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
@@ -44,6 +44,24 @@
* [*Range Return Type:] `boost::tokenized_range<typeof(rng)>`
* [*Returned Range Category:] __random_access_range__
+[section:tokenized_example tokenized_example]
+[import ../../../test/adaptor_test/tokenized_example.cpp]
+[tokenized_example]
+[endsect]
+
+This would produce the output:
+``
+a
+b
+c
+d
+e
+f
+g
+hijklmnopqrstuvwxyz
+
+``
+
[endsect]
Modified: trunk/libs/range/test/Jamfile.v2
==============================================================================
--- trunk/libs/range/test/Jamfile.v2 (original)
+++ trunk/libs/range/test/Jamfile.v2 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
@@ -31,7 +31,6 @@
}
test-suite range :
- [ compile ../doc/reference/adaptors/examples/tokenized.cpp : : example_tokenized ]
[ compile-fail compile_fail/iterator_range1.cpp ]
[ range-test adaptor_test/adjacent_filtered ]
[ range-test adaptor_test/copied ]
@@ -47,6 +46,7 @@
[ range-test adaptor_test/strided2 ]
[ range-test adaptor_test/tokenized ]
[ range-test adaptor_test/transformed ]
+ [ range-test adaptor_test/type_erased ]
[ range-test adaptor_test/uniqued ]
[ range-test adaptor_test/adjacent_filtered_example ]
[ range-test adaptor_test/copied_example ]
@@ -61,7 +61,7 @@
[ range-test adaptor_test/sliced_example ]
[ range-test adaptor_test/strided_example ]
[ range-test adaptor_test/transformed_example ]
- [ range-test adaptor_test/type_erased ]
+ [ range-test adaptor_test/tokenized_example ]
[ range-test adaptor_test/type_erased_example ]
[ range-test adaptor_test/uniqued_example ]
[ range-test algorithm_test/adjacent_find ]
Added: trunk/libs/range/test/adaptor_test/tokenized_example.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/adaptor_test/tokenized_example.cpp 2013-01-03 19:58:17 EST (Thu, 03 Jan 2013)
@@ -0,0 +1,65 @@
+// Boost.Range library
+//
+// Copyright Neil Groves 2009. Use, modification and
+// distribution is subject to 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)
+//
+//
+// For more information, see http://www.boost.org/libs/range/
+//
+//[tokenized_example
+#include <boost/range/adaptor/tokenized.hpp>
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/assign.hpp>
+#include <algorithm>
+#include <iostream>
+#include <vector>
+
+//<-
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <boost/range/algorithm_ext/push_back.hpp>
+
+namespace
+{
+void tokenized_example_test()
+//->
+//=int main(int argc, const char* argv[])
+{
+ using namespace boost::adaptors;
+
+ typedef boost::sub_match< std::string::iterator > match_type;
+
+ std::string input = " a b c d e f g hijklmnopqrstuvwxyz";
+ boost::copy(
+ input | tokenized(boost::regex("\\w+")),
+ std::ostream_iterator<match_type>(std::cout, "\n"));
+
+//= return 0;
+//=}
+//]
+ using namespace boost::assign;
+
+ std::vector<std::string> reference;
+ reference += "a","b","c","d","e","f","g","hijklmnopqrstuvwxyz";
+
+ std::vector<match_type> test;
+ boost::push_back(test, input | tokenized(boost::regex("\\w+")));
+
+ BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
+ test.begin(), test.end() );
+}
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.tokenized_example" );
+
+ test->add( BOOST_TEST_CASE( &tokenized_example_test ) );
+
+ return test;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk