|
Boost-Commit : |
From: nesotto_at_[hidden]
Date: 2007-11-05 08:54:24
Author: nesotto
Date: 2007-11-05 08:54:23 EST (Mon, 05 Nov 2007)
New Revision: 40785
URL: http://svn.boost.org/trac/boost/changeset/40785
Log:
added lost changes from 1.34 branch
Removed:
trunk/libs/assign/test/TODO
Text files modified:
trunk/libs/assign/doc/index.html | 72 +++++++++++++++++++++++++++++++++------
trunk/libs/assign/doc/style.css | 7 +++
trunk/libs/assign/index.html | 14 +++++--
3 files changed, 77 insertions(+), 16 deletions(-)
Modified: trunk/libs/assign/doc/index.html
==============================================================================
--- trunk/libs/assign/doc/index.html (original)
+++ trunk/libs/assign/doc/index.html 2007-11-05 08:54:23 EST (Mon, 05 Nov 2007)
@@ -37,7 +37,7 @@
<li>Function list_of()
<li>Function map_list_of()
<li>Function tuple_list_of()
- <li>Functions repeat()
and repeat_fun()
+ <li>Functions repeat()
, repeat_fun()
and range()
<li>Functions ref_list_of()
and cref_list_of()
<li>A "complicated" example
<li>Functions <a href="#ptr_push_back"><code>ptr_push_back(), ptr_push_front()</code>,
@@ -50,7 +50,8 @@
<li>Headers </li>
<li>Standard containers </li>
<li>Functions list_of()
and map_list_of()
</li>
- <li>Functions repeat()
and repeat_fun()
+ <li>Functions <a href="#repeat_ref"><code>repeat()</code>,
+ <code>repeat_fun()</code> and <code>range()</code> </a> </li>
<li>Class list_inserter
</li>
<li>Function make_list_inserter()
</li>
<li> Customizing argument list sizes</li>
@@ -118,7 +119,7 @@
<li>Function list_of()
<li>Function map_list_of()
<li>Function tuple_list_of()
- <li>Functions repeat()
and repeat_fun()
+ <li>Functions repeat()
, repeat_fun()
and range()
<li>Functions ref_list_of()
and cref_list_of()
<li>A "complicated" example
<li>Functions ptr_push_back(), ptr_push_front()
, ptr_insert()
and ptr_map_insert()
@@ -336,7 +337,7 @@
</pre>
</blockquote>
-<h3>Functions <code>repeat()</code> and <code>repeat_fun()</code> <a name="repeat"></h3>
+<h3>Functions <code>repeat()</code>, <code>repeat_fun()</code> and <code>range()</code> <a name="repeat"></h3>
<p>
Sometimes it is too irritating to repeat the same value many times. This is
where <code>repeat()</code> can be handy:
@@ -406,6 +407,40 @@
The only requirement of the second argument to <code>repeat_fun()</code> is that
it is a nullary function. </p>
+
+<p>
+If you just need to insert an iterator-range somewhere in the list, the member function <code>range()</code> provides just what you want.
+It is based on Boost.Range, so you can pass all the ranges supported by that library. For example
+<blockquote><pre><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>list_inserter</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span> <span class=comment>// for 'push_back()'</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>list_of</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span> <span class=comment>// for 'list_of()' and 'ref_list_of()'</span>
+<span class=preprocessor>#include</span> <span class=special><</span><span class=identifier>boost</span><span class=special>/</span><span class=identifier>assert</span><span class=special>.</span><span class=identifier>hpp</span><span class=special>></span>
+
+<span class=keyword>using</span> <span class=keyword>namespace</span> <span class=identifier>std</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>assign</span><span class=special>;</span>
+
+<span class=special>{</span>
+ <span class=identifier>vector</span><span class=special><</span><span class=keyword>int</span><span class=special>></span> <span class=identifier>v</span><span class=special>,</span> <span class=identifier>v2</span><span class=special>;</span>
+ <span class=identifier>v</span> <span class=special>=</span> <span class=identifier>list_of</span><span class=special>(</span><span class=number>1</span><span class=special>)(</span><span class=number>2</span><span class=special>)(</span><span class=number>3</span><span class=special>);</span>
+ <span class=identifier>v2</span> <span class=special>=</span> <span class=identifier>list_of</span><span class=special>(</span><span class=number>0</span><span class=special>).</span><span class=identifier>range</span><span class=special>(</span><span class=identifier>v</span><span class=special>).</span><span class=identifier>range</span><span class=special>(</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>v</span><span class=special>.</span><span class=identifier>end</span><span class=special>())(</span><span class=number>4</span><span class=special>);</span>
+ <span class=comment>// v2 = [0,1,2,3,1,2,3,4]</span>
+ <span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>v2</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>8u</span> <span class=special>);</span>
+
+ <span class=identifier>push_back</span><span class=special>(</span> <span class=identifier>v</span> <span class=special>).</span><span class=identifier>range</span><span class=special>(</span><span class=identifier>v2</span><span class=special>)(</span><span class=number>5</span><span class=special>);</span>
+ <span class=comment>// v = [1,2,3,0,1,2,3,1,2,3,4,5]</span>
+ <span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>v</span><span class=special>.</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>12u</span> <span class=special>);</span>
+
+ <span class=comment>//
+ // create a list of references, some coming from a container, others from the stack
+ //</span>
+ <span class=keyword>int</span> <span class=identifier>x</span> <span class=special>=</span> <span class=number>0</span><span class=special>;</span>
+ <span class=keyword>int</span> <span class=identifier>y</span> <span class=special>=</span> <span class=number>1</span><span class=special>;</span>
+ <span class=identifier>BOOST_ASSERT</span><span class=special>(</span> <span class=identifier>ref_list_of</span><span class=special><</span><span class=number>10</span><span class=special>>(</span><span class=identifier>x</span><span class=special>).</span><span class=identifier>range</span><span class=special>(</span><span class=identifier>v2</span><span class=special>)(</span><span class=identifier>y</span><span class=special>).</span><span class=identifier>size</span><span class=special>()</span> <span class=special>==</span> <span class=number>10u</span> <span class=special>);</span>
+<span class=special>}</span></pre>
+</blockquote>
+As you can see, one can also pass two iterators if that is more appropriate.
+The last example also introduces list of references. More about that below.
+</p>
+
<h3>Functions <code>ref_list_of()</code> and <code>cref_list_of()</code> <a name="ref_list_of"></h3>
When you need to create an anonymous range of values and speed is essential,
@@ -615,13 +650,13 @@
</span>
<span class=special>{
</span><span class=identifier>ptr_deque</span><span class=special><</span><span class=identifier>Foo</span><span class=special>> </span><span class=identifier>deq</span><span class=special>;
- </span><span class=identifier>deq </span><span class=special>= </span><span class=identifier>ptr_list_of</span><span class=special><</span><span class=identifier>Foo</span><span class=special>>( </span><span class=number>42 </span><span class=special>)()()( </span><span class=number>3</span><span class=special>, </span><span class=number>3 </span><span class=special>)( </span><span class=string>"foo"</span><span class=special>, </span><span class=number>2</span><span class=special>, </span><span class=number>1 </span><span class=special>).</span><span class=identifier>to_container</span><span class=special>( </span><span class=identifier>deq </span><span class=special>);
+ </span><span class=identifier>deq </span><span class=special>= </span><span class=identifier>ptr_list_of</span><span class=special><</span><span class=identifier>Foo</span><span class=special>>( </span><span class=number>42 </span><span class=special>)()()( </span><span class=number>3</span><span class=special>, </span><span class=number>3 </span><span class=special>)( </span><span class=string>"foo"</span><span class=special>, </span><span class=number>2</span><span class=special>, </span><span class=number>1 </span><span class=special>);
</span><span class=identifier>BOOST_CHECK</span><span class=special>( </span><span class=identifier>deq</span><span class=special>.</span><span class=identifier>size</span><span class=special>() </span><span class=special>== </span><span class=number>5 </span><span class=special>);</span>
<span class=special>}</span>
</pre>
</blockquote>
-Notice the trailing <code>.to_container(deq)</code> which helps many poor
+Notice that a trailing <code>.to_container(deq)</code> may be added to help many poor
compilers to figure out the conversion (a few get it right).
Notice also that pointer maps are
not supported.
@@ -684,7 +719,9 @@
<li>Headers </li>
<li>Standard containers </li>
<li>Functions list_of()
and map_list_of()
</li>
- <li>Functions repeat()
and repeat_fun()
</li>
+ <li>Functions <a href="#repeat_ref"><code>repeat()</code>,<code>repeat_fun()</code> and
+ <code>range()</code>
+ </a></li>
<li>Class list_inserter
</li>
<li>Function make_list_inserter()
</li>
<li>Customizing argument list sizes </li>
@@ -917,11 +954,13 @@
<span class=special>} </span><span class=comment>// namespace 'assign'</span>
<span class=special>} </span><span class=comment>// namespace 'boost'</span> </pre></blockquote>
- <h3>Functions <code>repeat()</code> and
- <code>repeat_fun()</code> <a name="repeat_ref"> </h3>
+
+ <h3>Functions <code>repeat()</code>,
+ <code>repeat_fun()</code> and <code>range()</code> <a name="repeat_ref"> </h3>
<p>
- These two function exist both as free-standing functions and as member functions of the object returned by
- <code>list_of()</code> and of <code>list_inserter</code>. The free-standing versions are used to create a
+ These first two function exist both as free-standing functions and as member functions of the object returned by
+ <code>list_of()</code> and of <code>list_inserter</code>.
+ The free-standing versions are used to create a
hook for <code>operator,()</code> so we can call the functions in the middle of a comma-list. The member functions
are used when we need to call the functions in the middle of a parenthesis-list. In both cases we have that
<ul>
@@ -930,6 +969,17 @@
<li> the argument list of <code>repeat_fun()</code> is <code>(std::size_t,Nullary_function)</code>
</ul>
+ </p>
+ <p>
+ The function <code>range()</code> only exists as a member function. The following two overloads are provided:
+ <blockquote>
+ <pre><span class=keyword>template</span><span class=special><</span> <span class=keyword>class</span> <span class=identifier>SinglePassIterator</span> <span class=special>></span>
+<span class=identifier>Implementation</span><span class=special>-</span><span class=identifier>defined</span> <span class=identifier>range</span><span class=special>(</span> <span class=identifier>SinglePassIterator</span> <span class=identifier>first</span><span class=special>,</span> <span class=identifier>SinglePassIterator</span> <span class=identifier>last</span> <span class=special>);</span>
+
+<span class=keyword>template</span><span class=special><</span> <span class=keyword>class</span> <span class=identifier>SinglePassRange</span> <span class=special>></span>
+<span class=identifier>Implementation</span><span class=special>-</span><span class=identifier>defined</span> <span class=identifier>range</span><span class=special>(</span> <span class=keyword>const</span> <span class=identifier>SinglePassRange</span><span class=special>&</span> <span class=identifier>rng</span> <span class=special>);</span></pre>
+ </blockquote>
+
</p>
<h3><a name="list_inserter">Class <code>list_inserter</code></a></h3>
Modified: trunk/libs/assign/doc/style.css
==============================================================================
--- trunk/libs/assign/doc/style.css (original)
+++ trunk/libs/assign/doc/style.css 2007-11-05 08:54:23 EST (Mon, 05 Nov 2007)
@@ -1,3 +1,10 @@
+/*
+#// Copyright Thorsten Ottosen 2003-2005. 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)
+*/
+
pre{
BORDER-RIGHT: gray 1pt solid;
PADDING-RIGHT: 2pt;
Modified: trunk/libs/assign/index.html
==============================================================================
--- trunk/libs/assign/index.html (original)
+++ trunk/libs/assign/index.html 2007-11-05 08:54:23 EST (Mon, 05 Nov 2007)
@@ -10,11 +10,15 @@
<body>
Automatic redirection failed, please go to
-doc/index.html <hr>
-<p>© Copyright Beman Dawes, 2001</p>
-<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
+doc/index.html
+ <p>
+ Copyright © 2003-2007 Thorsten Ottosen. Use, modification and distribution is
+ subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt)
+ (See accompanying
file LICENSE_1_0.txt or copy
-at www.boost.org/LICENSE_1_0.txt)</p>
+at www.boost.org/LICENSE_1_0.txt)
+ </p>
</body>
</html></body>
-</html>
\ No newline at end of file
+
+</html>
Deleted: trunk/libs/assign/test/TODO
==============================================================================
--- trunk/libs/assign/test/TODO 2007-11-05 08:54:23 EST (Mon, 05 Nov 2007)
+++ (empty file)
@@ -1,34 +0,0 @@
-0. add description of empty () for list_of(), list_inserter.
-1. add repeat description
-
-3. docs may mention whether hash_map/set can be used
- as well as upcoming boost::unordered_map/set.
-
- Maybe exotic containers as circular_buffer and/or
- multi index container can be shown in example as well.
-
-4. update docs wrt member function addresses + std namespace
-5. update email example to use a local functor
-
-6: find conversion problem in g++ with nested list_of().
-7. add repeat etc to header overview.
-
-8. Consider optimising generic_list to store only references
- to the object in the list. Even if compound objects are
- stored, then maybe tuples of opetional<T&> can be stored
- and construction deferred until the conversion to a
- container is needed. A special iterator could construct
- the objects on demand
-
-9. The decay problem should be solved once and for all by something like
-
- template< class T >
- generic_list< decay_array<T>::type > list_of( const T& );
-
- or decay_traits<T>::type
-
-10. Consider adding list_of and iterable_list_of to complement each other.
- However, for tight code, list_of<7> works pretty well and provides
- random_access iterators. recursive_list_of(2)(6);
-
-11. make begin()/end() const members
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