mirror of
https://github.com/boostorg/utility.git
synced 2025-10-06 22:10:54 +02:00
Compare commits
9 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
|
d9c9685be2 | ||
|
31d0908b74 | ||
|
32c77599f4 | ||
|
812ebf3562 | ||
|
37f476013d | ||
|
9f3104166f | ||
|
64cc0daf34 | ||
|
d5d64df124 | ||
|
0edcfcd5c1 |
@@ -85,7 +85,7 @@ Once that is done we can drop Multi-Pass Input Iterator.
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
<A HREF=file:///c:/boost/site/people/jeremy_siek.htm>Jeremy Siek</A>, Univ.of Notre Dame (<A HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)
|
||||
</TD></TR></TABLE>
|
||||
|
||||
</BODY>
|
||||
|
@@ -9,6 +9,9 @@
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 25 Jun 01 output_iterator_helper changes: removed default template
|
||||
// parameters, added support for self-proxying, additional
|
||||
// documentation and tests (Aleksey Gurtovoy)
|
||||
// 29 May 01 Added operator classes for << and >>. Added input and output
|
||||
// iterator helper classes. Added classes to connect equality and
|
||||
// relational operators. Added classes for groups of related
|
||||
@@ -701,17 +704,17 @@ struct input_iterator_helper
|
||||
, dereferenceable<T, P
|
||||
, boost::iterator<std::input_iterator_tag, V, D, P, R
|
||||
> > > > {};
|
||||
#ifndef BOOST_MSVC
|
||||
template <class T,
|
||||
class V = void,
|
||||
class D = void,
|
||||
class P = void,
|
||||
class R = void>
|
||||
|
||||
template<class Derived>
|
||||
struct output_iterator_helper
|
||||
: incrementable<T
|
||||
, boost::iterator<std::output_iterator_tag, V, D, P, R
|
||||
> > {};
|
||||
#endif
|
||||
: boost::incrementable<Derived
|
||||
, boost::iterator<std::output_iterator_tag, void, void, void, void
|
||||
> >
|
||||
{
|
||||
Derived& operator*() { return static_cast<Derived&>(*this); }
|
||||
Derived& operator++() { return static_cast<Derived&>(*this); }
|
||||
};
|
||||
|
||||
template <class T,
|
||||
class V,
|
||||
class D = std::ptrdiff_t,
|
||||
|
@@ -4,8 +4,6 @@
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
// 27 June 2001 Jeremy Siek
|
||||
// Upated for change in named params.
|
||||
// 8 Mar 2001 Jeremy Siek
|
||||
// Initial checkin.
|
||||
|
||||
@@ -13,6 +11,9 @@
|
||||
#include <boost/pending/iterator_tests.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
class bar { };
|
||||
void foo(bar) { }
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -25,8 +26,9 @@ main()
|
||||
|
||||
{
|
||||
typedef boost::iterator_adaptor<my_iter, boost::default_iterator_policies,
|
||||
boost::reference_is<dummyT>,
|
||||
boost::iterator_category_is<std::input_iterator_tag> > iter_type;
|
||||
boost::iterator_traits_generator
|
||||
::reference<dummyT>
|
||||
::iterator_category<std::input_iterator_tag> > iter_type;
|
||||
|
||||
BOOST_STATIC_ASSERT((boost::is_same<iter_type::iterator_category*,
|
||||
std::input_iterator_tag*>::value));
|
||||
@@ -40,11 +42,12 @@ main()
|
||||
{
|
||||
typedef boost::iterator_adaptor<dummyT*,
|
||||
boost::default_iterator_policies,
|
||||
boost::value_type_is<dummyT>,
|
||||
boost::reference_is<const dummyT&>,
|
||||
boost::pointer_is<const dummyT*>,
|
||||
boost::iterator_category_is<std::forward_iterator_tag>,
|
||||
boost::difference_type_is<std::ptrdiff_t> > adaptor_type;
|
||||
boost::iterator_traits_generator
|
||||
::value_type<dummyT>
|
||||
::reference<const dummyT&>
|
||||
::pointer<const dummyT*>
|
||||
::iterator_category<std::forward_iterator_tag>
|
||||
::difference_type<std::ptrdiff_t> > adaptor_type;
|
||||
|
||||
adaptor_type i(array);
|
||||
|
@@ -21,8 +21,9 @@ main(int, char*[])
|
||||
int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
|
||||
typedef std::binder1st< std::multiplies<int> > Function;
|
||||
typedef boost::transform_iterator_generator<Function, int*
|
||||
>::type doubling_iterator;
|
||||
typedef boost::transform_iterator<Function, int*,
|
||||
boost::iterator<std::random_access_iterator_tag, int>
|
||||
>::type doubling_iterator;
|
||||
|
||||
doubling_iterator i(x, std::bind1st(std::multiplies<int>(), 2)),
|
||||
i_end(x + sizeof(x)/sizeof(int), std::bind1st(std::multiplies<int>(), 2));
|
||||
|
@@ -9,7 +9,6 @@
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 27 June 01 Updated to changes in named parameters.
|
||||
// 08 Mar 01 Moved indirect and transform tests to separate files.
|
||||
// (Jeremy Siek)
|
||||
// 19 Feb 01 Take adavantage of improved iterator_traits to do more tests
|
||||
@@ -53,7 +52,8 @@
|
||||
#include <boost/pending/iterator_tests.hpp>
|
||||
#include <boost/pending/integer_range.hpp>
|
||||
#include <boost/concept_archetype.hpp>
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
|
||||
@@ -97,9 +97,6 @@ typedef std::deque<int> storage;
|
||||
typedef std::deque<int*> pointer_deque;
|
||||
typedef std::set<storage::iterator> iterator_set;
|
||||
|
||||
struct bar { };
|
||||
void foo(bar) { }
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
@@ -309,11 +306,12 @@ main()
|
||||
#else
|
||||
typedef boost::iterator_adaptor<boost::forward_iterator_archetype<dummyT>,
|
||||
boost::default_iterator_policies,
|
||||
boost::value_type_is<dummyT>,
|
||||
boost::reference_is<const dummyT&>,
|
||||
boost::pointer_is<const dummyT*>,
|
||||
boost::iterator_category_is<std::forward_iterator_tag>,
|
||||
boost::difference_type_is<std::ptrdiff_t> > adaptor_type;
|
||||
boost::iterator_traits_generator
|
||||
::value_type<dummyT>
|
||||
::reference<const dummyT&>
|
||||
::pointer<const dummyT*>
|
||||
::iterator_category<std::forward_iterator_tag>
|
||||
::difference_type<std::ptrdiff_t> > adaptor_type;
|
||||
#endif
|
||||
adaptor_type i(forward_iter);
|
||||
int zero = 0;
|
||||
|
@@ -93,7 +93,7 @@
|
||||
<a href="function_output_iterator.htm">Function Output Iterator Adaptor</a>
|
||||
</ul>
|
||||
|
||||
<p><b><a href="http://www.boost.org/people/dave_abrahams.htm">Dave
|
||||
<p><b><a href="file:///c:/boost/site/people/dave_abrahams.htm">Dave
|
||||
Abrahams</a></b> started the library, applying <a href=
|
||||
"../../more/generic_programming.html#policy">policy class</a> technique and
|
||||
handling const/non-const iterator interactions. He also contributed the
|
||||
@@ -102,7 +102,7 @@
|
||||
<tt><a href="counting_iterator.htm">counting_iterator_generator</a></tt> to
|
||||
cover all incrementable types. He edited most of the documentation,
|
||||
sometimes heavily.<br>
|
||||
<b><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy
|
||||
<b><a href="file:///c:/boost/site/people/jeremy_siek.htm">Jeremy
|
||||
Siek</a></b> contributed the <a href="transform_iterator.htm">transform
|
||||
iterator</a> adaptor, the integer-only version of <tt><a href=
|
||||
"counting_iterator.htm">counting_iterator_generator</a></tt>,
|
||||
@@ -860,7 +860,7 @@ bool operator==(const iterator_adaptor<B1,P,V1,R1,P1,C,D>&,
|
||||
<hr>
|
||||
|
||||
<p>Revised
|
||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->19 Mar 2001<!--webbot bot="Timestamp" endspan i-checksum="14895" -->
|
||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %b %Y" startspan -->12 Jul 2001<!--webbot bot="Timestamp" endspan i-checksum="14985" -->
|
||||
|
||||
|
||||
<p>© Copyright Dave Abrahams and Jeremy Siek 2001. Permission to copy,
|
||||
|
@@ -26,6 +26,10 @@
|
||||
#include <string> // for std::string
|
||||
#include <strstream> // for std::ostrstream
|
||||
|
||||
# ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::strcmp; }
|
||||
# endif
|
||||
|
||||
|
||||
// Iterator test class
|
||||
template <class T, class R, class P>
|
||||
|
@@ -7,6 +7,7 @@
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 1 Apr 2001 Fixes for ICL; use BOOST_STATIC_CONSTANT
|
||||
// 11 Feb 2001 Fixes for Borland (David Abrahams)
|
||||
// 23 Jan 2001 Added test for wchar_t (David Abrahams)
|
||||
// 23 Jan 2001 Now statically selecting a test for signed numbers to avoid
|
||||
@@ -30,13 +31,6 @@
|
||||
# include <limits>
|
||||
#endif
|
||||
|
||||
// A macro for declaring class compile-time constants.
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
# define DECLARE_CLASS_CONST(type, init) static const type init
|
||||
#else
|
||||
# define DECLARE_CLASS_CONST(type, init) enum { init }
|
||||
#endif
|
||||
|
||||
// =================================================================================
|
||||
// template class complement_traits<Number> --
|
||||
//
|
||||
@@ -53,8 +47,8 @@ template <unsigned size> struct complement; // forward
|
||||
template <class Number, unsigned size>
|
||||
struct complement_traits_aux
|
||||
{
|
||||
DECLARE_CLASS_CONST(Number, max = complement<size>::template traits<Number>::max);
|
||||
DECLARE_CLASS_CONST(Number, min = complement<size>::template traits<Number>::min);
|
||||
BOOST_STATIC_CONSTANT(Number, max = complement<size>::template traits<Number>::max);
|
||||
BOOST_STATIC_CONSTANT(Number, min = complement<size>::template traits<Number>::min);
|
||||
};
|
||||
|
||||
template <unsigned size>
|
||||
@@ -67,11 +61,11 @@ struct complement
|
||||
// indirection through complement_traits_aux neccessary to keep MSVC happy
|
||||
typedef complement_traits_aux<Number, size - 1> prev;
|
||||
public:
|
||||
DECLARE_CLASS_CONST(Number, max =
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
Number(Number(prev::max) << CHAR_BIT)
|
||||
+ Number(UCHAR_MAX));
|
||||
|
||||
DECLARE_CLASS_CONST(Number, min = Number(Number(prev::min) << CHAR_BIT));
|
||||
BOOST_STATIC_CONSTANT(Number, min = Number(Number(prev::min) << CHAR_BIT));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -85,8 +79,8 @@ template <> struct complement_base<false>
|
||||
template <class Number>
|
||||
struct values
|
||||
{
|
||||
DECLARE_CLASS_CONST(Number, min = 0);
|
||||
DECLARE_CLASS_CONST(Number, max = UCHAR_MAX);
|
||||
BOOST_STATIC_CONSTANT(Number, min = 0);
|
||||
BOOST_STATIC_CONSTANT(Number, max = UCHAR_MAX);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -95,8 +89,8 @@ template <> struct complement_base<true>
|
||||
template <class Number>
|
||||
struct values
|
||||
{
|
||||
DECLARE_CLASS_CONST(Number, min = SCHAR_MIN);
|
||||
DECLARE_CLASS_CONST(Number, max = SCHAR_MAX);
|
||||
BOOST_STATIC_CONSTANT(Number, min = SCHAR_MIN);
|
||||
BOOST_STATIC_CONSTANT(Number, max = SCHAR_MAX);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -107,10 +101,10 @@ struct complement<1>
|
||||
template <class Number>
|
||||
struct traits
|
||||
{
|
||||
DECLARE_CLASS_CONST(bool, is_signed = boost::detail::is_signed<Number>::value);
|
||||
DECLARE_CLASS_CONST(Number, min =
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = boost::detail::is_signed<Number>::value);
|
||||
BOOST_STATIC_CONSTANT(Number, min =
|
||||
complement_base<is_signed>::template values<Number>::min);
|
||||
DECLARE_CLASS_CONST(Number, max =
|
||||
BOOST_STATIC_CONSTANT(Number, max =
|
||||
complement_base<is_signed>::template values<Number>::max);
|
||||
};
|
||||
};
|
||||
@@ -121,8 +115,8 @@ struct complement<1>
|
||||
template <class Number>
|
||||
struct complement_traits
|
||||
{
|
||||
DECLARE_CLASS_CONST(Number, max = (complement_traits_aux<Number, sizeof(Number)>::max));
|
||||
DECLARE_CLASS_CONST(Number, min = (complement_traits_aux<Number, sizeof(Number)>::min));
|
||||
BOOST_STATIC_CONSTANT(Number, max = (complement_traits_aux<Number, sizeof(Number)>::max));
|
||||
BOOST_STATIC_CONSTANT(Number, min = (complement_traits_aux<Number, sizeof(Number)>::min));
|
||||
};
|
||||
|
||||
// =================================================================================
|
||||
@@ -151,9 +145,9 @@ template <> struct stream_as<signed char> {
|
||||
typedef unsigned char t1; typedef unsigned t2;
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) // No intmax streaming built-in
|
||||
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
|
||||
|
||||
// On this platform, __int64 and __uint64 get streamed as strings
|
||||
// With this library implementation, __int64 and __uint64 get streamed as strings
|
||||
template <> struct stream_as<boost::uintmax_t> {
|
||||
typedef std::string t1;
|
||||
typedef std::string t2;
|
||||
@@ -174,7 +168,7 @@ template <class T> struct promote
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) // No intmax streaming built-in
|
||||
#if defined(BOOST_MSVC_STD_ITERATOR) // No intmax streaming built-in
|
||||
|
||||
// On this platform, stream them as long/unsigned long if they fit.
|
||||
// Otherwise, write a string.
|
||||
|
@@ -50,6 +50,7 @@ provided by the class.</p>
|
||||
<ul>
|
||||
<li><a href="#dereference">Dereference operators</a></li>
|
||||
<li><a href="#iterator">Iterator Helpers</a></li>
|
||||
<li><a href="#iterator_helpers_notes">Iterator Helper Notes</a></li>
|
||||
<li><a href="#i_demo">Iterator Demonstration and Test
|
||||
Program</a></li>
|
||||
</ul></li>
|
||||
@@ -821,7 +822,7 @@ from previous versions of the header, cannot be used for
|
||||
<p>The <cite><a href="operators_test.cpp">operators_test.cpp</a></cite>
|
||||
program demonstrates the use of the arithmetic operator templates, and
|
||||
can also be used to verify correct operation. Check the <a
|
||||
href="../compiler_status.htm">compiler status report</a> for the test results
|
||||
href="../../status/compiler_status.html">compiler status report</a> for the test results
|
||||
with selected platforms.</p>
|
||||
|
||||
<h2><a name="deref">Dereference</a> Operators and Iterator Helpers</h2>
|
||||
@@ -889,7 +890,7 @@ href="#chaining">base class chaining</a>.</p>
|
||||
|
||||
<h3><a name="iterator">Iterator</a> Helpers</h3>
|
||||
|
||||
<p>There are three separate iterator helper classes, each for a
|
||||
<p>There are five separate iterator helper classes, each for a
|
||||
different category of iterator. Here is a summary of the core set of
|
||||
operators that the custom iterator must define, and the extra operators
|
||||
that are created by the helper classes. These classes cannot be used for <a
|
||||
@@ -931,11 +932,13 @@ C++ standard (<code>iterator_category</code>, <code>value_type</code>,
|
||||
</ul></td>
|
||||
</tr>
|
||||
<tr valign="baseline">
|
||||
<td><code><a name="output_iterator_helper">output_iterator_helper<T, V, D, P, R></a></code></td>
|
||||
<td><code><a name="output_iterator_helper">output_iterator_helper<T></a></code></td>
|
||||
<td>Supports the operations and has the requirements of
|
||||
<ul>
|
||||
<li><code><a href="#incrementable">incrementable<T></a></code></li>
|
||||
</ul></td>
|
||||
</ul>
|
||||
See also [<a href="#1">1</a>], [<a href="#2">2</a>].
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="baseline">
|
||||
<td><code><a name="forward_iterator_helper">forward_iterator_helper<T, V, D, P, R></a></code></td>
|
||||
@@ -975,6 +978,53 @@ C++ standard (<code>iterator_category</code>, <code>value_type</code>,
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3><a name="iterator_helpers_notes">Iterator Helper Notes</a></h3>
|
||||
|
||||
<p><a name="1">[1]</a> Unlike other iterator helpers templates,
|
||||
<code>output_iterator_helper</code> takes only one template parameter - the type of
|
||||
its target class. Although to some it might seem like an unnecessary
|
||||
restriction, the standard requires <code>difference_type</code> and
|
||||
<code>value_type</code> of any output iterator to be
|
||||
<code>void</code> (24.3.1 [lib.iterator.traits]), and
|
||||
<code>output_iterator_helper</code> template respects this
|
||||
requirement. Also, output iterators in the standard have void <tt>pointer</tt> and
|
||||
<tt>reference</tt> types, so the <tt>output_iterator_helper</tt> does the
|
||||
same.
|
||||
|
||||
<p><a name="2">[2]</a> As self-proxying is the easiest and most common way to
|
||||
implement output iterators (see, for example, insert [24.4.2] and stream
|
||||
iterators [24.5] in the standard library), <code>output_iterator_helper</code>
|
||||
supports the idiom by defining <code>operator*</code>
|
||||
and <code>operator++</code> member functions which just return a
|
||||
non-const reference to the iterator itself. Support for
|
||||
self-proxying allows us, in many cases, to reduce the task of writing an output
|
||||
iterator to writing just two member functions - an appropriate
|
||||
constructor and a copy-assignment operator. For example, here is a possible
|
||||
implementation of <code><a href="function_output_iterator.htm">boost::function_output_iterator</a></code>
|
||||
adaptor:</p>
|
||||
|
||||
<pre>
|
||||
template<class UnaryFunction>
|
||||
struct function_output_iterator
|
||||
: boost::output_iterator_helper< function_output_iterator<UnaryFunction> >
|
||||
{
|
||||
explicit function_output_iterator(UnaryFunction const& f = UnaryFunction())
|
||||
: func(f) {}
|
||||
|
||||
template<typename T>
|
||||
function_output_iterator& operator=(T const& value)
|
||||
{
|
||||
this->func(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
UnaryFunction func;
|
||||
};
|
||||
</pre>
|
||||
|
||||
<p>Note that support for self-proxying does not prevent you from using <code>output_iterator_helper</code> to ease any other, different kind of output iterator's implementation. If <code>output_iterator_helper</code>'s target type provides its own definition of <code>operator*</code> or/and <code>operator++</code>, then these operators will get used and the ones supplied by <code>output_iterator_helper</code> will never be instantiated.</p>
|
||||
|
||||
<h3><a name="i_demo">Iterator Demonstration</a> and Test Program</h3>
|
||||
|
||||
<p>The <cite><a href="iterators_test.cpp">iterators_test.cpp</a></cite>
|
||||
@@ -1010,7 +1060,7 @@ public:
|
||||
};</pre>
|
||||
</blockquote>
|
||||
|
||||
<p>Check the <a href="../compiler_status.htm">compiler status report</a> for
|
||||
<p>Check the <a href="../../status/compiler_status.html">compiler status report</a> for
|
||||
the test results with selected platforms.</p>
|
||||
|
||||
<hr>
|
||||
@@ -1092,7 +1142,7 @@ the library remain backward-compatible.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>Revised: 20 May 2001</p>
|
||||
<p>Revised: 25 Jun 2001</p>
|
||||
|
||||
<p>Copyright © David Abrahams and Beman Dawes 1999-2001.
|
||||
Permission to copy, use, modify, sell and distribute this document is
|
||||
|
6
tie.html
6
tie.html
@@ -23,7 +23,9 @@
|
||||
<TT>tie</TT>
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
<h3>
|
||||
[tie has been deprecated. Its functionality is supplied by the Boost
|
||||
Tuples Library.]</h3>
|
||||
<PRE>
|
||||
template <class A, class B>
|
||||
tied<A,B> tie(A& a, B& b);
|
||||
@@ -124,7 +126,7 @@ The output is:
|
||||
<TABLE>
|
||||
<TR valign=top>
|
||||
<TD nowrap>Copyright © 2000</TD><TD>
|
||||
<A HREF=http://www.boost.org/people/jeremy_siek.htm>Jeremy Siek</A>,
|
||||
<A HREF=file:///c:/boost/site/people/jeremy_siek.htm>Jeremy Siek</A>,
|
||||
Univ.of Notre Dame (<A
|
||||
HREF="mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</A>)<br>
|
||||
<A HREF=http://www.lsc.nd.edu/~llee1>Lie-Quan Lee</A>, Univ.of Notre Dame (<A HREF="mailto:llee1@lsc.nd.edu">llee1@lsc.nd.edu</A>)<br>
|
||||
|
Reference in New Issue
Block a user