diff --git a/doc/headers.qbk b/doc/headers.qbk index 0012c6a..3107018 100644 --- a/doc/headers.qbk +++ b/doc/headers.qbk @@ -8,7 +8,7 @@ [section:general General] [table [[Header ] [Includes ] [Related Concept ]] - [[`` ] [everything from Boost.Range version 1 (Boost versions 1.42 and below). Includes the core range functions and metafunctinos, but excludes Range Adaptors and Range Algorithms. ] [- ]] + [[`` ] [everything from Boost.Range version 1 (Boost versions 1.42 and below). Includes the core range functions and metafunctions, but excludes Range Adaptors and Range Algorithms. ] [- ]] [[`` ] [every metafunction ] [- ]] [[`` ] [every function ] [- ]] [[`` ] [__range_value__ ] [__single_pass_range__ ]] diff --git a/doc/html/index.html b/doc/html/index.html index e67d025..301224a 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -147,7 +147,7 @@

- +

Last revised: December 13, 2012 at 06:53:49 GMT

Last revised: January 14, 2013 at 08:50:06 GMT


diff --git a/doc/html/range/headers/general.html b/doc/html/range/headers/general.html index 7020f7a..c4abe19 100644 --- a/doc/html/range/headers/general.html +++ b/doc/html/range/headers/general.html @@ -59,7 +59,7 @@

everything from Boost.Range version 1 (Boost versions 1.42 and - below). Includes the core range functions and metafunctinos, but + below). Includes the core range functions and metafunctions, but excludes Range Adaptors and Range Algorithms.

diff --git a/doc/html/range/reference/adaptors/introduction.html b/doc/html/range/reference/adaptors/introduction.html index 3253f5c..665f9de 100644 --- a/doc/html/range/reference/adaptors/introduction.html +++ b/doc/html/range/reference/adaptors/introduction.html @@ -204,7 +204,7 @@

std::vector<int> vec;
-boost::replace_copy_if( rng, std::back_inserter(vec), pred );
+boost::replace_copy_if( rng, std::back_inserter(vec), pred, new_value );
 

diff --git a/doc/html/range/reference/adaptors/reference/adjacent_filtered.html b/doc/html/range/reference/adaptors/reference/adjacent_filtered.html index f83b737..91772cf 100644 --- a/doc/html/range/reference/adaptors/reference/adjacent_filtered.html +++ b/doc/html/range/reference/adaptors/reference/adjacent_filtered.html @@ -112,7 +112,7 @@
#include <boost/range/adaptor/adjacent_filtered.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <functional>
 #include <iostream>
 #include <vector>
@@ -138,7 +138,7 @@
 

This would produce the output:

-
1,2,3,4,5,6
+
1,2,3,4,5,6,
 

diff --git a/doc/html/range/reference/adaptors/reference/copied.html b/doc/html/range/reference/adaptors/reference/copied.html index 6902098..16ba126 100644 --- a/doc/html/range/reference/adaptors/reference/copied.html +++ b/doc/html/range/reference/adaptors/reference/copied.html @@ -109,7 +109,7 @@
#include <boost/range/adaptor/copied.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -134,7 +134,7 @@
 

This would produce the output:

-
2,3,4,5
+
2,3,4,5,
 

diff --git a/doc/html/range/reference/adaptors/reference/filtered.html b/doc/html/range/reference/adaptors/reference/filtered.html index 5d45709..84c6df2 100644 --- a/doc/html/range/reference/adaptors/reference/filtered.html +++ b/doc/html/range/reference/adaptors/reference/filtered.html @@ -112,7 +112,7 @@
#include <boost/range/adaptor/filtered.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -132,6 +132,8 @@
     boost::copy(
         input | filtered(is_even()),
         std::ostream_iterator<int>(std::cout, ","));
+
+    return 0;
 }
 

@@ -140,7 +142,7 @@

This would produce the output:

-
2,4,6,8
+
2,4,6,8,
 

diff --git a/doc/html/range/reference/adaptors/reference/indexed.html b/doc/html/range/reference/adaptors/reference/indexed.html index ab6a776..4a2d29f 100644 --- a/doc/html/range/reference/adaptors/reference/indexed.html +++ b/doc/html/range/reference/adaptors/reference/indexed.html @@ -55,7 +55,7 @@

rng | - boost::adaptors::indexed + boost::adaptors::indexed(start_index)

@@ -67,7 +67,8 @@

- boost::adaptors::index(rng) + boost::adaptors::index(rng, + start_index)

@@ -104,7 +105,7 @@
#include <boost/range/adaptor/indexed.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -123,27 +124,6 @@
     display_element_and_index(boost::begin(rng), boost::end(rng));
 }
 
-template<class Iterator1, class Iterator2>
-void check_element_and_index(
-        Iterator1 test_first,
-        Iterator1 test_last,
-        Iterator2 reference_first,
-        Iterator2 reference_last)
-{
-    BOOST_CHECK_EQUAL( std::distance(test_first, test_last),
-                       std::distance(reference_first, reference_last) );
-
-    int reference_index = 0;
-
-    Iterator1 test_it = test_first;
-    Iterator2 reference_it = reference_first;
-    for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index)
-    {
-        BOOST_CHECK_EQUAL( *test_it, *reference_it );
-        BOOST_CHECK_EQUAL( test_it.index(), reference_index );
-    }
-}
-
 int main(int argc, const char* argv[])
 {
     using namespace boost::assign;
diff --git a/doc/html/range/reference/adaptors/reference/indirected.html b/doc/html/range/reference/adaptors/reference/indirected.html
index d185d79..f2ea353 100644
--- a/doc/html/range/reference/adaptors/reference/indirected.html
+++ b/doc/html/range/reference/adaptors/reference/indirected.html
@@ -108,7 +108,7 @@
 
#include <boost/range/adaptor/indirected.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/shared_ptr.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -134,7 +134,7 @@
 

This would produce the output:

-
0,1,2,3,4,5,6,7,8,9
+
0,1,2,3,4,5,6,7,8,9,
 

diff --git a/doc/html/range/reference/adaptors/reference/map_keys.html b/doc/html/range/reference/adaptors/reference/map_keys.html index 58c164f..c7f05a3 100644 --- a/doc/html/range/reference/adaptors/reference/map_keys.html +++ b/doc/html/range/reference/adaptors/reference/map_keys.html @@ -107,7 +107,7 @@
#include <boost/range/adaptor/map.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <map>
 #include <vector>
@@ -134,7 +134,7 @@
 

This would produce the output:

-
0,1,2,3,4,5,6,7,8,9
+
0,1,2,3,4,5,6,7,8,9,
 

diff --git a/doc/html/range/reference/adaptors/reference/map_values.html b/doc/html/range/reference/adaptors/reference/map_values.html index d467ffb..22008da 100644 --- a/doc/html/range/reference/adaptors/reference/map_values.html +++ b/doc/html/range/reference/adaptors/reference/map_values.html @@ -109,7 +109,7 @@
#include <boost/range/adaptor/map.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <map>
 #include <vector>
@@ -136,7 +136,7 @@
 

This would produce the output:

-
0,10,20,30,40,50,60,70,80,90
+
0,10,20,30,40,50,60,70,80,90,
 

diff --git a/doc/html/range/reference/adaptors/reference/replaced.html b/doc/html/range/reference/adaptors/reference/replaced.html index a0fc28e..d70b2d5 100644 --- a/doc/html/range/reference/adaptors/reference/replaced.html +++ b/doc/html/range/reference/adaptors/reference/replaced.html @@ -125,7 +125,7 @@
#include <boost/range/adaptor/replaced.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -150,7 +150,7 @@
 

This would produce the output:

-
1,10,3,10,5,10,7,10,9
+
1,10,3,10,5,10,7,10,9,
 

diff --git a/doc/html/range/reference/adaptors/reference/replaced_if.html b/doc/html/range/reference/adaptors/reference/replaced_if.html index 05b26b3..e5363d3 100644 --- a/doc/html/range/reference/adaptors/reference/replaced_if.html +++ b/doc/html/range/reference/adaptors/reference/replaced_if.html @@ -121,7 +121,7 @@
#include <boost/range/adaptor/replaced_if.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -151,7 +151,7 @@
 

This would produce the output:

-
1,10,3,10,5,10,7,10,9
+
1,10,3,10,5,10,7,10,9,
 

diff --git a/doc/html/range/reference/adaptors/reference/reversed.html b/doc/html/range/reference/adaptors/reference/reversed.html index 1db2af4..ab61716 100644 --- a/doc/html/range/reference/adaptors/reference/reversed.html +++ b/doc/html/range/reference/adaptors/reference/reversed.html @@ -100,11 +100,11 @@
#include <boost/range/adaptor/reversed.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
-void reversed_example_test()
+int main(int argc, const char* argv[])
 {
     using namespace boost::adaptors;
     using namespace boost::assign;
@@ -125,7 +125,7 @@
 

This would produce the output:

-
9,8,7,6,5,4,3,2,1
+
9,8,7,6,5,4,3,2,1,
 

diff --git a/doc/html/range/reference/adaptors/reference/sliced.html b/doc/html/range/reference/adaptors/reference/sliced.html index 1f4e63d..664ee47 100644 --- a/doc/html/range/reference/adaptors/reference/sliced.html +++ b/doc/html/range/reference/adaptors/reference/sliced.html @@ -110,7 +110,7 @@
#include <boost/range/adaptor/sliced.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -135,7 +135,7 @@
 

This would produce the output:

-
3,4,5
+
3,4,5,
 

diff --git a/doc/html/range/reference/adaptors/reference/strided.html b/doc/html/range/reference/adaptors/reference/strided.html index 8ff19e1..b16af14 100644 --- a/doc/html/range/reference/adaptors/reference/strided.html +++ b/doc/html/range/reference/adaptors/reference/strided.html @@ -102,7 +102,7 @@
#include <boost/range/adaptor/strided.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -127,7 +127,7 @@
 

This would produce the output:

-
1,3,5,7,9
+
1,3,5,7,9,
 

diff --git a/doc/html/range/reference/adaptors/reference/tokenized.html b/doc/html/range/reference/adaptors/reference/tokenized.html index 1b9a97d..ec50b79 100644 --- a/doc/html/range/reference/adaptors/reference/tokenized.html +++ b/doc/html/range/reference/adaptors/reference/tokenized.html @@ -26,6 +26,7 @@ +
@@ -134,6 +135,50 @@ Access Range +
+ +

+

+
#include <boost/range/adaptor/tokenized.hpp>
+#include <boost/range/algorithm/copy.hpp>
+#include <boost/assign.hpp>
+#include <iterator>
+#include <iostream>
+#include <vector>
+
+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;
+}
+
+

+

+
+

+ This would produce the output: +

+
a
+b
+c
+d
+e
+f
+g
+hijklmnopqrstuvwxyz
+
+

+

diff --git a/doc/html/range/reference/adaptors/reference/transformed.html b/doc/html/range/reference/adaptors/reference/transformed.html index 9a272b0..5f38ed5 100644 --- a/doc/html/range/reference/adaptors/reference/transformed.html +++ b/doc/html/range/reference/adaptors/reference/transformed.html @@ -113,7 +113,7 @@
#include <boost/range/adaptor/transformed.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
@@ -144,7 +144,7 @@
 

This would produce the output:

-
2,4,6,8,10,12,14,16,18,20
+
2,4,6,8,10,12,14,16,18,20,
 

diff --git a/doc/html/range/reference/adaptors/reference/type_erased.html b/doc/html/range/reference/adaptors/reference/type_erased.html index 20430be..f0a5ce6 100644 --- a/doc/html/range/reference/adaptors/reference/type_erased.html +++ b/doc/html/range/reference/adaptors/reference/type_erased.html @@ -190,7 +190,7 @@ #include <boost/range/algorithm/copy.hpp> #include <boost/assign.hpp> #include <boost/foreach.hpp> -#include <algorithm> +#include <iterator> #include <iostream> #include <list> #include <vector> @@ -279,10 +279,10 @@

This would produce the output:

-
1,2,3,4,5
-6,7,8,9,10
-11,12,13,14,15
-11,12,13,14,15
+
1,2,3,4,5,
+6,7,8,9,10,
+11,12,13,14,15,
+11,12,13,14,15,
 

diff --git a/doc/html/range/reference/adaptors/reference/uniqued.html b/doc/html/range/reference/adaptors/reference/uniqued.html index 2ef82e0..cf3b672 100644 --- a/doc/html/range/reference/adaptors/reference/uniqued.html +++ b/doc/html/range/reference/adaptors/reference/uniqued.html @@ -105,11 +105,11 @@
#include <boost/range/adaptor/uniqued.hpp>
 #include <boost/range/algorithm/copy.hpp>
 #include <boost/assign.hpp>
-#include <algorithm>
+#include <iterator>
 #include <iostream>
 #include <vector>
 
-void uniqued_example_test()
+int main(int argc, const char* argv[])
 {
     using namespace boost::assign;
     using namespace boost::adaptors;
@@ -120,6 +120,8 @@
     boost::copy(
         input | uniqued,
         std::ostream_iterator<int>(std::cout, ","));
+
+    return 0;
 }
 

@@ -128,7 +130,7 @@

This would produce the output:

-
1,2,3,4,5,6
+
1,2,3,4,5,6,
 

diff --git a/doc/html/range/reference/algorithms/heap/pop_heap.html b/doc/html/range/reference/algorithms/heap/pop_heap.html index 633ba1f..996ba5d 100644 --- a/doc/html/range/reference/algorithms/heap/pop_heap.html +++ b/doc/html/range/reference/algorithms/heap/pop_heap.html @@ -52,8 +52,8 @@

pop_heap removes the - largest element from the heap. It is assumed that begin(rng), prior(end(rng)) is already a heap and that the element - to be added is *prior(end(rng)). + largest element from the heap. It is assumed that begin(rng), prior(end(rng)) is already a heap (and therefore the + largest element is *begin(rng)).

The ordering relationship is determined by using operator< in the non-predicate versions, and diff --git a/doc/html/range/reference/algorithms/numeric/inner_product.html b/doc/html/range/reference/algorithms/numeric/inner_product.html index 4c2742d..2db9eb5 100644 --- a/doc/html/range/reference/algorithms/numeric/inner_product.html +++ b/doc/html/range/reference/algorithms/numeric/inner_product.html @@ -47,7 +47,8 @@ Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init, - BinaryOperation1 op1 ); + BinaryOperation1 op1, + BinaryOperation2 op2 );

diff --git a/doc/html/range/reference/extending/method_3/method_3_1.html b/doc/html/range/reference/extending/method_3/method_3_1.html index 10283cb..6628403 100644 --- a/doc/html/range/reference/extending/method_3/method_3_1.html +++ b/doc/html/range/reference/extending/method_3/method_3_1.html @@ -81,6 +81,14 @@ { return reverse_range<const BidirectionalRng>( r ); } +
+ +
  • + Declare the adaptor itself (it is a variable of the tag type). +
    namespace
    +{
    +    const detail::reverse_forwarder reversed = detail::reverse_forwarder();
    +}
     
  • diff --git a/doc/html/range/reference/extending/method_3/method_3_2.html b/doc/html/range/reference/extending/method_3/method_3_2.html index 829179a..e21cd5f 100644 --- a/doc/html/range/reference/extending/method_3/method_3_2.html +++ b/doc/html/range/reference/extending/method_3/method_3_2.html @@ -80,15 +80,8 @@
  • Implement a holder class to hold the arguments required to construct - the RangeAdaptor. -
  • - -

    - The holder combines multiple parameters into one that can be passed as - the right operand of operator|(). -

    -

    -

    + the RangeAdaptor. The holder combines multiple parameters into one + that can be passed as the right operand of operator|().
    template<typename T>
     class replace_holder : public boost::range_detail::holder2<T>
     {
    @@ -100,23 +93,15 @@
         void operator=(const replace_holder&);
     };
     
    -

    -

    -
    1. +
    2. +
    3. Define an instance of the holder with the name of the adaptor -
    -

    -

    static boost::range_detail::forwarder2<replace_holder>
     replaced = boost::range_detail::forwarder2<replace_holder>();
     
    -

    -

    -
    1. +
    2. +
    3. Define operator| -
    -

    -

    template<typename SinglePassRange>
     inline replace_range<SinglePassRange>
     operator|(SinglePassRange& rng,
    @@ -133,8 +118,8 @@
         return replace_range<const SinglePassRange>(rng, f.val1, f.val2);
     }
     
    -

    -

    + +
    diff --git a/doc/reference/adaptors.qbk b/doc/reference/adaptors.qbk index 91401c0..96f2ca3 100644 --- a/doc/reference/adaptors.qbk +++ b/doc/reference/adaptors.qbk @@ -93,7 +93,7 @@ What this means is that ['*no*] algorithm with the `_if` suffix is needed. Furth `` std::vector vec; -boost::replace_copy_if( rng, std::back_inserter(vec), pred ); +boost::replace_copy_if( rng, std::back_inserter(vec), pred, new_value ); `` With adaptors and algorithms we can express this as diff --git a/doc/reference/adaptors/adjacent_filtered.qbk b/doc/reference/adaptors/adjacent_filtered.qbk index a15f992..f8b4289 100644 --- a/doc/reference/adaptors/adjacent_filtered.qbk +++ b/doc/reference/adaptors/adjacent_filtered.qbk @@ -19,35 +19,13 @@ * [*Returned Range Category:] The minimum of the range category of `rng` and __forward_range__ [section:adjacent_filtered_example adjacent_filtered example] -`` -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,1,2,2,2,3,4,5,6; - - boost::copy( - input | adjacent_filtered(std::not_equal_to()), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/adjacent_filtered_example.cpp] +[adjacent_filtered_example] [endsect] This would produce the output: `` -1,2,3,4,5,6 +1,2,3,4,5,6, `` [endsect] diff --git a/doc/reference/adaptors/copied.qbk b/doc/reference/adaptors/copied.qbk index 69ee46d..2a8abcc 100644 --- a/doc/reference/adaptors/copied.qbk +++ b/doc/reference/adaptors/copied.qbk @@ -17,34 +17,13 @@ * [*Returned Range Category:] __random_access_range__ [section:copied_example copied example] -`` -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | copied(1, 5), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/copied_example.cpp] +[copied_example] [endsect] This would produce the output: `` -2,3,4,5 +2,3,4,5, `` [endsect] diff --git a/doc/reference/adaptors/examples/adjacent_filtered.cpp b/doc/reference/adaptors/examples/adjacent_filtered.cpp deleted file mode 100644 index cc7cd9b..0000000 --- a/doc/reference/adaptors/examples/adjacent_filtered.cpp +++ /dev/null @@ -1,32 +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 -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,1,2,2,2,3,4,5,6; - - boost::copy( - input | adjacent_filtered(std::not_equal_to()), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/copied.cpp b/doc/reference/adaptors/examples/copied.cpp deleted file mode 100644 index 2de46ab..0000000 --- a/doc/reference/adaptors/examples/copied.cpp +++ /dev/null @@ -1,31 +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 -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | copied(1, 5), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/filtered.cpp b/doc/reference/adaptors/examples/filtered.cpp deleted file mode 100644 index 6471237..0000000 --- a/doc/reference/adaptors/examples/filtered.cpp +++ /dev/null @@ -1,36 +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 -#include -#include -#include -#include -#include - -struct is_even -{ - bool operator()(int x) const { return x % 2 == 0; } -}; - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | filtered(is_even()), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/indexed.cpp b/doc/reference/adaptors/examples/indexed.cpp deleted file mode 100644 index bb141e8..0000000 --- a/doc/reference/adaptors/examples/indexed.cpp +++ /dev/null @@ -1,45 +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 -#include -#include -#include -#include -#include - -template -void display_element_and_index(Iterator first, Iterator last) -{ - for (Iterator it = first; it != last; ++it) - { - std::cout << "Element = " << *it - << " Index = " << it.index() << std::endl; - } -} - -template -void display_element_and_index(const SinglePassRange& rng) -{ - display_element_and_index(boost::begin(rng), boost::end(rng)); -} - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 10,20,30,40,50,60,70,80,90; - - display_element_and_index( input | indexed(0) ); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/map_keys.cpp b/doc/reference/adaptors/examples/map_keys.cpp deleted file mode 100644 index 006e7e9..0000000 --- a/doc/reference/adaptors/examples/map_keys.cpp +++ /dev/null @@ -1,33 +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 -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::map input; - for (int i = 0; i < 10; ++i) - input.insert(std::make_pair(i, i * 10)); - - boost::copy( - input | map_keys, - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/map_values.cpp b/doc/reference/adaptors/examples/map_values.cpp deleted file mode 100644 index a0fa651..0000000 --- a/doc/reference/adaptors/examples/map_values.cpp +++ /dev/null @@ -1,33 +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 -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::map input; - for (int i = 0; i < 10; ++i) - input.insert(std::make_pair(i, i * 10)); - - boost::copy( - input | map_values, - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/replaced.cpp b/doc/reference/adaptors/examples/replaced.cpp deleted file mode 100644 index 7b85ba1..0000000 --- a/doc/reference/adaptors/examples/replaced.cpp +++ /dev/null @@ -1,31 +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 -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,2,5,2,7,2,9; - - boost::copy( - input | replaced(2, 10), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/replaced_if.cpp b/doc/reference/adaptors/examples/replaced_if.cpp deleted file mode 100644 index 23952f7..0000000 --- a/doc/reference/adaptors/examples/replaced_if.cpp +++ /dev/null @@ -1,35 +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 -#include -#include -#include -#include -#include - -struct is_even -{ - bool operator()(int x) const { return x % 2 == 0; } -}; - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | replaced_if(is_even(), 10), - std::ostream_iterator(std::cout, ",")); - - return 0; -} diff --git a/doc/reference/adaptors/examples/reversed.cpp b/doc/reference/adaptors/examples/reversed.cpp deleted file mode 100644 index 85696cb..0000000 --- a/doc/reference/adaptors/examples/reversed.cpp +++ /dev/null @@ -1,31 +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 -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | reversed, - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/sliced.cpp b/doc/reference/adaptors/examples/sliced.cpp deleted file mode 100644 index cc8b9cb..0000000 --- a/doc/reference/adaptors/examples/sliced.cpp +++ /dev/null @@ -1,31 +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 -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | sliced(2, 5), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/strided.cpp b/doc/reference/adaptors/examples/strided.cpp deleted file mode 100644 index f12b72a..0000000 --- a/doc/reference/adaptors/examples/strided.cpp +++ /dev/null @@ -1,31 +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 -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | strided(2), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/tokenized.cpp b/doc/reference/adaptors/examples/tokenized.cpp deleted file mode 100644 index 273eaf1..0000000 --- a/doc/reference/adaptors/examples/tokenized.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include - -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; -} diff --git a/doc/reference/adaptors/examples/transformed.cpp b/doc/reference/adaptors/examples/transformed.cpp deleted file mode 100644 index 62bf5d4..0000000 --- a/doc/reference/adaptors/examples/transformed.cpp +++ /dev/null @@ -1,37 +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 -#include -#include -#include -#include -#include - -struct double_int -{ - typedef int result_type; - int operator()(int x) const { return x * 2; } -}; - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | transformed(double_int()), - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/examples/uniqued.cpp b/doc/reference/adaptors/examples/uniqued.cpp deleted file mode 100644 index a7b2f8e..0000000 --- a/doc/reference/adaptors/examples/uniqued.cpp +++ /dev/null @@ -1,31 +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 -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,1,2,2,2,3,4,5,6; - - boost::copy( - input | uniqued, - std::ostream_iterator(std::cout, ",")); - - return 0; -} - diff --git a/doc/reference/adaptors/filtered.qbk b/doc/reference/adaptors/filtered.qbk index 1b14524..3f84c94 100644 --- a/doc/reference/adaptors/filtered.qbk +++ b/doc/reference/adaptors/filtered.qbk @@ -19,37 +19,13 @@ * [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__ [section:filtered_example filtered example] -`` -#include -#include -#include -#include -#include -#include - -struct is_even -{ - bool operator()( int x ) const { return x % 2 == 0; } -}; - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | filtered(is_even()), - std::ostream_iterator(std::cout, ",")); -} -`` +[import ../../../test/adaptor_test/filtered_example.cpp] +[filtered_example] [endsect] This would produce the output: `` -2,4,6,8 +2,4,6,8, `` [endsect] diff --git a/doc/reference/adaptors/indexed.qbk b/doc/reference/adaptors/indexed.qbk index 9778f20..117e1e3 100644 --- a/doc/reference/adaptors/indexed.qbk +++ b/doc/reference/adaptors/indexed.qbk @@ -7,8 +7,8 @@ [table [[Syntax] [Code]] - [[Pipe] [`rng | boost::adaptors::indexed`]] - [[Function] [`boost::adaptors::index(rng)`]] + [[Pipe] [`rng | boost::adaptors::indexed(start_index)`]] + [[Function] [`boost::adaptors::index(rng, start_index)`]] ] * [*Returns:] A range adapted to return both the element and the associated index. The returned range consists of iterators that have in addition to the usual iterator member functions an `index()` member function that returns the appropriate index for the element in the sequence corresponding with the iterator. @@ -17,63 +17,8 @@ * [*Returned Range Category:] The range category of `rng` [section:indexed_example indexed example] -`` -#include -#include -#include -#include -#include -#include - -template -void display_element_and_index(Iterator first, Iterator last) -{ - for (Iterator it = first; it != last; ++it) - { - std::cout << "Element = " << *it << " Index = " << it.index() << std::endl; - } -} - -template -void display_element_and_index(const SinglePassRange& rng) -{ - display_element_and_index(boost::begin(rng), boost::end(rng)); -} - -template -void check_element_and_index( - Iterator1 test_first, - Iterator1 test_last, - Iterator2 reference_first, - Iterator2 reference_last) -{ - BOOST_CHECK_EQUAL( std::distance(test_first, test_last), - std::distance(reference_first, reference_last) ); - - int reference_index = 0; - - Iterator1 test_it = test_first; - Iterator2 reference_it = reference_first; - for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index) - { - BOOST_CHECK_EQUAL( *test_it, *reference_it ); - BOOST_CHECK_EQUAL( test_it.index(), reference_index ); - } -} - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 10,20,30,40,50,60,70,80,90; - - display_element_and_index( input | indexed(0) ); - - return 0; -} -`` +[import ../../../test/adaptor_test/indexed_example.cpp] +[indexed_example] [endsect] This would produce the output: diff --git a/doc/reference/adaptors/indirected.qbk b/doc/reference/adaptors/indirected.qbk index 5a1ed05..437a547 100644 --- a/doc/reference/adaptors/indirected.qbk +++ b/doc/reference/adaptors/indirected.qbk @@ -18,35 +18,13 @@ * [*Returned Range Category:] The range category of `rng` [section:indirected_example indirected example] -`` -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - - std::vector > input; - - for (int i = 0; i < 10; ++i) - input.push_back(boost::shared_ptr(new int(i))); - - boost::copy( - input | indirected, - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/indirected_example.cpp] +[indirected_example] [endsect] This would produce the output: `` -0,1,2,3,4,5,6,7,8,9 +0,1,2,3,4,5,6,7,8,9, `` [endsect] diff --git a/doc/reference/adaptors/map_keys.qbk b/doc/reference/adaptors/map_keys.qbk index 01b9d34..f9fbb9a 100644 --- a/doc/reference/adaptors/map_keys.qbk +++ b/doc/reference/adaptors/map_keys.qbk @@ -18,36 +18,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:map_keys_example map_keys example] -`` -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::map input; - for (int i = 0; i < 10; ++i) - input.insert(std::make_pair(i, i * 10)); - - boost::copy( - input | map_keys, - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/map_keys_example.cpp] +[map_keys_example] [endsect] This would produce the output: `` -0,1,2,3,4,5,6,7,8,9 +0,1,2,3,4,5,6,7,8,9, `` [endsect] diff --git a/doc/reference/adaptors/map_values.qbk b/doc/reference/adaptors/map_values.qbk index 17ad9c4..7941f47 100644 --- a/doc/reference/adaptors/map_values.qbk +++ b/doc/reference/adaptors/map_values.qbk @@ -18,36 +18,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:map_values_example map_values example] -`` -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::map input; - for (int i = 0; i < 10; ++i) - input.insert(std::make_pair(i, i * 10)); - - boost::copy( - input | map_values, - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/map_values_example.cpp] +[map_values_example] [endsect] This would produce the output: `` -0,10,20,30,40,50,60,70,80,90 +0,10,20,30,40,50,60,70,80,90, `` [endsect] diff --git a/doc/reference/adaptors/replaced.qbk b/doc/reference/adaptors/replaced.qbk index 3df708c..aae4ece 100644 --- a/doc/reference/adaptors/replaced.qbk +++ b/doc/reference/adaptors/replaced.qbk @@ -20,34 +20,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:replaced_example replaced example] -`` -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,2,5,2,7,2,9; - - boost::copy( - input | replaced(2, 10), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/replaced_example.cpp] +[replaced_example] [endsect] This would produce the output: `` -1,10,3,10,5,10,7,10,9 +1,10,3,10,5,10,7,10,9, `` [endsect] diff --git a/doc/reference/adaptors/replaced_if.qbk b/doc/reference/adaptors/replaced_if.qbk index b160b34..f00c46a 100644 --- a/doc/reference/adaptors/replaced_if.qbk +++ b/doc/reference/adaptors/replaced_if.qbk @@ -20,39 +20,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:replaced_if_example replaced_if example] -`` -#include -#include -#include -#include -#include -#include - -struct is_even -{ - bool operator()(int x) const { return x % 2 == 0; } -}; - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | replaced_if(is_even(), 10), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/replaced_if_example.cpp] +[replaced_if_example] [endsect] This would produce the output: `` -1,10,3,10,5,10,7,10,9 +1,10,3,10,5,10,7,10,9, `` [endsect] diff --git a/doc/reference/adaptors/reversed.qbk b/doc/reference/adaptors/reversed.qbk index 7116475..42f8e73 100644 --- a/doc/reference/adaptors/reversed.qbk +++ b/doc/reference/adaptors/reversed.qbk @@ -17,34 +17,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:reversed_example reversed example] -`` -#include -#include -#include -#include -#include -#include - -void reversed_example_test() -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | reversed, - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/reversed_example.cpp] +[reversed_example] [endsect] This would produce the output: `` -9,8,7,6,5,4,3,2,1 +9,8,7,6,5,4,3,2,1, `` [endsect] diff --git a/doc/reference/adaptors/sliced.qbk b/doc/reference/adaptors/sliced.qbk index 33b57ca..e67ae30 100644 --- a/doc/reference/adaptors/sliced.qbk +++ b/doc/reference/adaptors/sliced.qbk @@ -18,34 +18,13 @@ * [*Returned Range Category:] __random_access_range__ [section:sliced_example sliced example] -`` -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | sliced(2, 5), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/sliced_example.cpp] +[sliced_example] [endsect] This would produce the output: `` -3,4,5 +3,4,5, `` [endsect] diff --git a/doc/reference/adaptors/strided.qbk b/doc/reference/adaptors/strided.qbk index e219a83..a672e3d 100644 --- a/doc/reference/adaptors/strided.qbk +++ b/doc/reference/adaptors/strided.qbk @@ -17,34 +17,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:strided_example strided example] -`` -#include -#include -#include -#include -#include -#include - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | strided(2), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/strided_example.cpp] +[strided_example] [endsect] This would produce the output: `` -1,3,5,7,9 +1,3,5,7,9, `` [endsect] diff --git a/doc/reference/adaptors/tokenized.qbk b/doc/reference/adaptors/tokenized.qbk index 2127785..0a480d4 100644 --- a/doc/reference/adaptors/tokenized.qbk +++ b/doc/reference/adaptors/tokenized.qbk @@ -44,6 +44,24 @@ * [*Range Return Type:] `boost::tokenized_range` * [*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] diff --git a/doc/reference/adaptors/transformed.qbk b/doc/reference/adaptors/transformed.qbk index ec19583..c53cfd7 100644 --- a/doc/reference/adaptors/transformed.qbk +++ b/doc/reference/adaptors/transformed.qbk @@ -19,40 +19,13 @@ * [*Returned Range Category:] The range category of `rng`. [section:transformed_example transformed example] -`` -#include -#include -#include -#include -#include -#include - -struct double_int -{ - typedef int result_type; - int operator()(int x) const { return x * 2; } -}; - -int main(int argc, const char* argv[]) -{ - using namespace boost::adaptors; - using namespace boost::assign; - - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | transformed(double_int()), - std::ostream_iterator(std::cout, ",")); - - return 0; -} -`` +[import ../../../test/adaptor_test/transformed_example.cpp] +[transformed_example] [endsect] This would produce the output: `` -2,4,6,8,10,12,14,16,18,20 +2,4,6,8,10,12,14,16,18,20, `` [endsect] diff --git a/doc/reference/adaptors/type_erased.qbk b/doc/reference/adaptors/type_erased.qbk index 9fb72a5..e55ff66 100644 --- a/doc/reference/adaptors/type_erased.qbk +++ b/doc/reference/adaptors/type_erased.qbk @@ -49,102 +49,16 @@ public: `` [section:type_erased_example type-erased example] -`` -#include -#include -#include -#include -#include -#include -#include -#include - -// The client interface from an OO perspective merely requires a sequence -// of integers that can be forward traversed -typedef boost::any_range< - int - , boost::forward_traversal_tag - , int - , std::ptrdiff_t -> integer_range; - -namespace server -{ - void display_integers(const integer_range& rng) - { - boost::copy(rng, - std::ostream_iterator(std::cout, ",")); - - std::cout << std::endl; - } -} - -namespace client -{ - void run() - { - using namespace boost::assign; - using namespace boost::adaptors; - - // Under most conditions one would simply use an appropriate - // any_range as a function parameter. The type_erased adaptor - // is often superfluous. However because the type_erased - // adaptor is applied to a range, we can use default template - // arguments that are generated in conjunction with the - // range type to which we are applying the adaptor. - - std::vector input; - input += 1,2,3,4,5; - - // Note that this call is to a non-template function - server::display_integers(input); - - std::list input2; - input2 += 6,7,8,9,10; - - // Note that this call is to the same non-tempate function - server::display_integers(input2); - - input2.clear(); - input2 += 11,12,13,14,15; - - // Calling using the adaptor looks like this: - // Notice that here I have a type_erased that would be a - // bidirectional_traversal_tag, but this is convertible - // to the forward_traversal_tag equivalent hence this - // works. - server::display_integers(input2 | type_erased<>()); - - // However we may simply wish to define an adaptor that - // takes a range and makes it into an appropriate - // forward_traversal any_range... - typedef boost::adaptors::type_erased< - boost::use_default - , boost::forward_traversal_tag - > type_erased_forward; - - // This adaptor can turn other containers with different - // value_types and reference_types into the appropriate - // any_range. - - server::display_integers(input2 | type_erased_forward()); - } -} - -int main(int argc, const char* argv[]) -{ - client::run(); - return 0; -} -`` +[import ../../../test/adaptor_test/type_erased_example.cpp] +[type_erased_example] [endsect] This would produce the output: `` -1,2,3,4,5 -6,7,8,9,10 -11,12,13,14,15 -11,12,13,14,15 +1,2,3,4,5, +6,7,8,9,10, +11,12,13,14,15, +11,12,13,14,15, `` [endsect] diff --git a/doc/reference/adaptors/uniqued.qbk b/doc/reference/adaptors/uniqued.qbk index a74d1a8..5b8e7f2 100644 --- a/doc/reference/adaptors/uniqued.qbk +++ b/doc/reference/adaptors/uniqued.qbk @@ -18,32 +18,13 @@ * [*Returned Range Category:] The minimum of the range concept of `rng` and __forward_range__. [section:uniqued_example uniqued example] -`` -#include -#include -#include -#include -#include -#include - -void uniqued_example_test() -{ - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 1,1,2,2,2,3,4,5,6; - - boost::copy( - input | uniqued, - std::ostream_iterator(std::cout, ",")); -} -`` +[import ../../../test/adaptor_test/uniqued_example.cpp] +[uniqued_example] [endsect] This would produce the output: `` -1,2,3,4,5,6 +1,2,3,4,5,6, `` [endsect] diff --git a/doc/reference/algorithm/pop_heap.qbk b/doc/reference/algorithm/pop_heap.qbk index 6950704..9008de4 100644 --- a/doc/reference/algorithm/pop_heap.qbk +++ b/doc/reference/algorithm/pop_heap.qbk @@ -23,7 +23,7 @@ const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare pred); [heading Description] -`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap and that the element to be added is `*prior(end(rng))`. +`pop_heap` removes the largest element from the heap. It is assumed that `begin(rng), prior(end(rng))` is already a heap (and therefore the largest element is `*begin(rng)`). The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions. diff --git a/doc/reference/extending.qbk b/doc/reference/extending.qbk index 6414e67..46652d6 100644 --- a/doc/reference/extending.qbk +++ b/doc/reference/extending.qbk @@ -218,6 +218,14 @@ operator|( const BidirectionalRng& r, detail::reverse_forwarder ) } `` +# Declare the adaptor itself (it is a variable of the tag type). +`` +namespace +{ + const detail::reverse_forwarder reversed = detail::reverse_forwarder(); +} +`` + [endsect] [section:method_3_2 Method 3.2: Implement a Range Adaptor with arguments] @@ -273,9 +281,7 @@ public: `` # Implement a holder class to hold the arguments required to construct the RangeAdaptor. - The holder combines multiple parameters into one that can be passed as the right operand of `operator|()`. - `` template class replace_holder : public boost::range_detail::holder2 @@ -290,14 +296,12 @@ private: `` # Define an instance of the holder with the name of the adaptor - `` static boost::range_detail::forwarder2 replaced = boost::range_detail::forwarder2(); `` # Define `operator|` - `` template inline replace_range diff --git a/doc/reference/numeric/inner_product.qbk b/doc/reference/numeric/inner_product.qbk index 1c6fc51..bb4fc3c 100644 --- a/doc/reference/numeric/inner_product.qbk +++ b/doc/reference/numeric/inner_product.qbk @@ -23,7 +23,8 @@ template #include #include -#include +#include #include #include #include +//<- #include #include @@ -23,27 +25,32 @@ namespace { - void adjacent_filtered_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; +void adjacent_filtered_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - std::vector input; - input += 1,1,2,2,2,3,4,5,6; + std::vector input; + input += 1,1,2,2,2,3,4,5,6; - boost::copy( - input | adjacent_filtered(std::not_equal_to()), - std::ostream_iterator(std::cout, ",")); + boost::copy( + input | adjacent_filtered(std::not_equal_to()), + std::ostream_iterator(std::cout, ",")); + +//= return 0; +//=} +//] + std::vector reference; + reference += 1,2,3,4,5,6; - std::vector reference; - reference += 1,2,3,4,5,6; + std::vector test; + boost::push_back(test, input | adjacent_filtered(std::not_equal_to())); - std::vector test; - boost::push_back(test, input | adjacent_filtered(std::not_equal_to())); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/copied_example.cpp b/test/adaptor_test/copied_example.cpp index 154a110..c1d0e31 100644 --- a/test/adaptor_test/copied_example.cpp +++ b/test/adaptor_test/copied_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[copied_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,28 +24,32 @@ namespace { - void copied_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; +void copied_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; - boost::copy( - input | copied(1, 5), - std::ostream_iterator(std::cout, ",")); + boost::copy( + input | copied(1, 5), + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector reference; + reference += 2,3,4,5; - std::vector reference; - reference += 2,3,4,5; + std::vector test; + boost::push_back(test, input | copied(1, 5)); - std::vector test; - boost::push_back(test, input | copied(1, 5)); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/filtered_example.cpp b/test/adaptor_test/filtered_example.cpp index 6d0e262..e16d0af 100644 --- a/test/adaptor_test/filtered_example.cpp +++ b/test/adaptor_test/filtered_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[filtered_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,32 +24,39 @@ namespace { - struct is_even - { - bool operator()( int x ) const { return x % 2 == 0; } - }; +//-> +struct is_even +{ + bool operator()( int x ) const { return x % 2 == 0; } +}; - void filtered_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; +//<- +void filtered_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - std::vector input; - input += 1,2,3,4,5,6,7,8,9; + std::vector input; + input += 1,2,3,4,5,6,7,8,9; - boost::copy( - input | filtered(is_even()), - std::ostream_iterator(std::cout, ",")); + boost::copy( + input | filtered(is_even()), + std::ostream_iterator(std::cout, ",")); - std::vector reference; - reference += 2,4,6,8; +//= return 0; +//=} +//] + std::vector reference; + reference += 2,4,6,8; - std::vector test; - boost::push_back(test, input | filtered(is_even())); + std::vector test; + boost::push_back(test, input | filtered(is_even())); - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/indexed_example.cpp b/test/adaptor_test/indexed_example.cpp index 14837d2..1bcbf9c 100644 --- a/test/adaptor_test/indexed_example.cpp +++ b/test/adaptor_test/indexed_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[indexed_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,65 +24,72 @@ namespace { - template - void display_element_and_index(Iterator first, Iterator last) + +template +void check_element_and_index( + Iterator1 test_first, + Iterator1 test_last, + Iterator2 reference_first, + Iterator2 reference_last) +{ + BOOST_CHECK_EQUAL( std::distance(test_first, test_last), + std::distance(reference_first, reference_last) ); + + int reference_index = 0; + + Iterator1 test_it = test_first; + Iterator2 reference_it = reference_first; + for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index) { - for (Iterator it = first; it != last; ++it) - { - std::cout << "Element = " << *it << " Index = " << it.index() << std::endl; - } + BOOST_CHECK_EQUAL( *test_it, *reference_it ); + BOOST_CHECK_EQUAL( test_it.index(), reference_index ); } +} - template - void display_element_and_index(const SinglePassRange& rng) +template +void check_element_and_index( + const SinglePassRange1& test_rng, + const SinglePassRange2& reference_rng) +{ + check_element_and_index(boost::begin(test_rng), boost::end(test_rng), + boost::begin(reference_rng), boost::end(reference_rng)); +} +//-> +template +void display_element_and_index(Iterator first, Iterator last) +{ + for (Iterator it = first; it != last; ++it) { - display_element_and_index(boost::begin(rng), boost::end(rng)); + std::cout << "Element = " << *it << " Index = " << it.index() << std::endl; } +} - template - void check_element_and_index( - Iterator1 test_first, - Iterator1 test_last, - Iterator2 reference_first, - Iterator2 reference_last) - { - BOOST_CHECK_EQUAL( std::distance(test_first, test_last), - std::distance(reference_first, reference_last) ); +template +void display_element_and_index(const SinglePassRange& rng) +{ + display_element_and_index(boost::begin(rng), boost::end(rng)); +} - int reference_index = 0; +//<- +void indexed_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - Iterator1 test_it = test_first; - Iterator2 reference_it = reference_first; - for (; test_it != test_last; ++test_it, ++reference_it, ++reference_index) - { - BOOST_CHECK_EQUAL( *test_it, *reference_it ); - BOOST_CHECK_EQUAL( test_it.index(), reference_index ); - } - } + std::vector input; + input += 10,20,30,40,50,60,70,80,90; - template - void check_element_and_index( - const SinglePassRange1& test_rng, - const SinglePassRange2& reference_rng) - { - check_element_and_index(boost::begin(test_rng), boost::end(test_rng), - boost::begin(reference_rng), boost::end(reference_rng)); - } + display_element_and_index( input | indexed(0) ); - void indexed_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; - - std::vector input; - input += 10,20,30,40,50,60,70,80,90; - - display_element_and_index( input | indexed(0) ); - - check_element_and_index( - input | indexed(0), - input); - } +//= return 0; +//=} +//] + check_element_and_index( + input | indexed(0), + input); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/indirected_example.cpp b/test/adaptor_test/indirected_example.cpp index 8e607a6..8b538b5 100644 --- a/test/adaptor_test/indirected_example.cpp +++ b/test/adaptor_test/indirected_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[indirected_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,30 +24,34 @@ namespace { - void indirected_example_test() - { - using namespace boost::adaptors; +void indirected_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; - std::vector > input; + std::vector > input; - for (int i = 0; i < 10; ++i) - input.push_back(boost::shared_ptr(new int(i))); - - boost::copy( - input | indirected, - std::ostream_iterator(std::cout, ",")); + for (int i = 0; i < 10; ++i) + input.push_back(boost::shared_ptr(new int(i))); + + boost::copy( + input | indirected, + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector reference; + for (int i = 0; i < 10; ++i) + reference.push_back(i); - std::vector reference; - for (int i = 0; i < 10; ++i) - reference.push_back(i); + std::vector test; + boost::push_back(test, input | indirected); - std::vector test; - boost::push_back(test, input | indirected); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/map_keys_example.cpp b/test/adaptor_test/map_keys_example.cpp index df85456..99f8505 100644 --- a/test/adaptor_test/map_keys_example.cpp +++ b/test/adaptor_test/map_keys_example.cpp @@ -8,14 +8,16 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[map_keys_example #include #include #include -#include +#include #include #include #include +//<- #include #include @@ -23,29 +25,33 @@ namespace { - void map_keys_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; +void map_keys_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - std::map input; - for (int i = 0; i < 10; ++i) - input.insert(std::make_pair(i, i * 10)); + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); - boost::copy( - input | map_keys, - std::ostream_iterator(std::cout, ",")); + boost::copy( + input | map_keys, + std::ostream_iterator(std::cout, ",")); - - std::vector reference; - reference += 0,1,2,3,4,5,6,7,8,9; +//= return 0; +//=} +//] + std::vector reference; + reference += 0,1,2,3,4,5,6,7,8,9; - std::vector test; - boost::push_back(test, input | map_keys); + std::vector test; + boost::push_back(test, input | map_keys); - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/map_values_example.cpp b/test/adaptor_test/map_values_example.cpp index dfb32e9..bfa533f 100644 --- a/test/adaptor_test/map_values_example.cpp +++ b/test/adaptor_test/map_values_example.cpp @@ -8,14 +8,16 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[map_values_example #include #include #include -#include +#include #include #include #include +//<- #include #include @@ -23,29 +25,33 @@ namespace { - void map_values_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; +void map_values_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - std::map input; - for (int i = 0; i < 10; ++i) - input.insert(std::make_pair(i, i * 10)); + std::map input; + for (int i = 0; i < 10; ++i) + input.insert(std::make_pair(i, i * 10)); - boost::copy( - input | map_values, - std::ostream_iterator(std::cout, ",")); + boost::copy( + input | map_values, + std::ostream_iterator(std::cout, ",")); - - std::vector reference; - reference += 0,10,20,30,40,50,60,70,80,90; +//= return 0; +//=} +//] + std::vector reference; + reference += 0,10,20,30,40,50,60,70,80,90; - std::vector test; - boost::push_back(test, input | map_values); + std::vector test; + boost::push_back(test, input | map_values); - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/replaced_example.cpp b/test/adaptor_test/replaced_example.cpp index fc1d2db..8e1f114 100644 --- a/test/adaptor_test/replaced_example.cpp +++ b/test/adaptor_test/replaced_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[replaced_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,28 +24,32 @@ namespace { - void replaced_example_test() - { - using namespace boost::adaptors; - using namespace boost::assign; +void replaced_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; - std::vector input; - input += 1,2,3,2,5,2,7,2,9; - - boost::copy( - input | replaced(2, 10), - std::ostream_iterator(std::cout, ",")); + std::vector input; + input += 1,2,3,2,5,2,7,2,9; + + boost::copy( + input | replaced(2, 10), + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector reference; + reference += 1,10,3,10,5,10,7,10,9; - std::vector reference; - reference += 1,10,3,10,5,10,7,10,9; + std::vector test; + boost::push_back(test, input | replaced(2, 10)); - std::vector test; - boost::push_back(test, input | replaced(2, 10)); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/replaced_if_example.cpp b/test/adaptor_test/replaced_if_example.cpp index c762c2f..05b5e78 100644 --- a/test/adaptor_test/replaced_if_example.cpp +++ b/test/adaptor_test/replaced_if_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[replaced_if_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,32 +24,39 @@ namespace { - struct is_even - { - bool operator()(int x) const { return x % 2 == 0; } - }; +//-> +struct is_even +{ + bool operator()(int x) const { return x % 2 == 0; } +}; - void replaced_if_example_test() - { - using namespace boost::adaptors; - using namespace boost::assign; +//<- +void replaced_if_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | replaced_if(is_even(), 10), - std::ostream_iterator(std::cout, ",")); + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | replaced_if(is_even(), 10), + std::ostream_iterator(std::cout, ",")); - std::vector reference; - reference += 1,10,3,10,5,10,7,10,9; +//= return 0; +//=} +//] + std::vector reference; + reference += 1,10,3,10,5,10,7,10,9; - std::vector test; - boost::push_back(test, input | replaced_if(is_even(), 10)); + std::vector test; + boost::push_back(test, input | replaced_if(is_even(), 10)); - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/reversed_example.cpp b/test/adaptor_test/reversed_example.cpp index 553e7d7..585108f 100644 --- a/test/adaptor_test/reversed_example.cpp +++ b/test/adaptor_test/reversed_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[reversed_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,25 +24,29 @@ namespace { - void reversed_example_test() - { - using namespace boost::adaptors; - using namespace boost::assign; +void reversed_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | reversed, - std::ostream_iterator(std::cout, ",")); + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | reversed, + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector test; + boost::push_back(test, input | reversed); - std::vector test; - boost::push_back(test, input | reversed); - - BOOST_CHECK_EQUAL_COLLECTIONS( input.rbegin(), input.rend(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( input.rbegin(), input.rend(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/sliced_example.cpp b/test/adaptor_test/sliced_example.cpp index 5761844..2b15691 100644 --- a/test/adaptor_test/sliced_example.cpp +++ b/test/adaptor_test/sliced_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[sliced_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,28 +24,32 @@ namespace { - void sliced_example_test() - { - using namespace boost::adaptors; - using namespace boost::assign; +void sliced_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; - std::vector input; - input += 1,2,3,4,5,6,7,8,9; - - boost::copy( - input | sliced(2, 5), - std::ostream_iterator(std::cout, ",")); + std::vector input; + input += 1,2,3,4,5,6,7,8,9; + + boost::copy( + input | sliced(2, 5), + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector reference; + reference += 3,4,5; - std::vector reference; - reference += 3,4,5; + std::vector test; + boost::push_back(test, input | sliced(2, 5)); - std::vector test; - boost::push_back(test, input | sliced(2, 5)); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/strided_example.cpp b/test/adaptor_test/strided_example.cpp index 5754c53..b1f8b42 100644 --- a/test/adaptor_test/strided_example.cpp +++ b/test/adaptor_test/strided_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[strided_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,28 +24,32 @@ namespace { - void strided_example_test() - { - using namespace boost::adaptors; - using namespace boost::assign; +void strided_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | strided(2), - std::ostream_iterator(std::cout, ",")); + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | strided(2), + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector reference; + reference += 1,3,5,7,9; - std::vector reference; - reference += 1,3,5,7,9; + std::vector test; + boost::push_back(test, input | strided(2)); - std::vector test; - boost::push_back(test, input | strided(2)); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/tokenized_example.cpp b/test/adaptor_test/tokenized_example.cpp new file mode 100644 index 0000000..5f59bb1 --- /dev/null +++ b/test/adaptor_test/tokenized_example.cpp @@ -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 +#include +#include +#include +#include +#include + +//<- +#include +#include + +#include + +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(std::cout, "\n")); + +//= return 0; +//=} +//] + using namespace boost::assign; + + std::vector reference; + reference += "a","b","c","d","e","f","g","hijklmnopqrstuvwxyz"; + + std::vector 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; +} diff --git a/test/adaptor_test/transformed_example.cpp b/test/adaptor_test/transformed_example.cpp index 3d05c95..ff4a689 100644 --- a/test/adaptor_test/transformed_example.cpp +++ b/test/adaptor_test/transformed_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[transformed_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,34 +24,40 @@ namespace { - struct double_int - { - typedef int result_type; - int operator()(int x) const { return x * 2; } - }; +//-> +struct double_int +{ + typedef int result_type; + int operator()(int x) const { return x * 2; } +}; - void transformed_example_test() - { - using namespace boost::adaptors; - using namespace boost::assign; +//<- +void transformed_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::adaptors; + using namespace boost::assign; - std::vector input; - input += 1,2,3,4,5,6,7,8,9,10; - - boost::copy( - input | transformed(double_int()), - std::ostream_iterator(std::cout, ",")); + std::vector input; + input += 1,2,3,4,5,6,7,8,9,10; + + boost::copy( + input | transformed(double_int()), + std::ostream_iterator(std::cout, ",")); +//= return 0; +//=} +//] + std::vector reference; + reference += 2,4,6,8,10,12,14,16,18,20; - std::vector reference; - reference += 2,4,6,8,10,12,14,16,18,20; + std::vector test; + boost::push_back(test, input | transformed(double_int())); - std::vector test; - boost::push_back(test, input | transformed(double_int())); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite* diff --git a/test/adaptor_test/type_erased_example.cpp b/test/adaptor_test/type_erased_example.cpp index 754fba6..f8416ae 100644 --- a/test/adaptor_test/type_erased_example.cpp +++ b/test/adaptor_test/type_erased_example.cpp @@ -8,15 +8,16 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[type_erased_example #include #include #include #include -#include +#include #include #include #include - +//<- #include #include @@ -26,6 +27,7 @@ namespace { namespace type_erased_example { +//-> // The client interface from an OO perspective merely requires a sequence // of integers that can be forward traversed @@ -99,6 +101,13 @@ namespace client } } +//=int main(int argc, const char* argv[]) +//={ +//= client::run(); +//= return 0; +//=} +//] + } // namespace type_erased_example } // namespace boost_range_test } // anonymous namespace diff --git a/test/adaptor_test/uniqued_example.cpp b/test/adaptor_test/uniqued_example.cpp index c48c54a..cf1407a 100644 --- a/test/adaptor_test/uniqued_example.cpp +++ b/test/adaptor_test/uniqued_example.cpp @@ -8,13 +8,15 @@ // // For more information, see http://www.boost.org/libs/range/ // +//[uniqued_example #include #include #include -#include +#include #include #include +//<- #include #include @@ -22,27 +24,32 @@ namespace { - void uniqued_example_test() - { - using namespace boost::assign; - using namespace boost::adaptors; +void uniqued_example_test() +//-> +//=int main(int argc, const char* argv[]) +{ + using namespace boost::assign; + using namespace boost::adaptors; - std::vector input; - input += 1,1,2,2,2,3,4,5,6; + std::vector input; + input += 1,1,2,2,2,3,4,5,6; - boost::copy( - input | uniqued, - std::ostream_iterator(std::cout, ",")); + boost::copy( + input | uniqued, + std::ostream_iterator(std::cout, ",")); - std::vector reference; - reference += 1,2,3,4,5,6; +//= return 0; +//=} +//] + std::vector reference; + reference += 1,2,3,4,5,6; - std::vector test; - boost::push_back( test, input | uniqued ); + std::vector test; + boost::push_back( test, input | uniqued ); - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); +} } boost::unit_test::test_suite*