From d6c6f0ce1669481699effe66894a81bf3cc24e54 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 5 Sep 2002 14:05:29 +0000 Subject: [PATCH 01/12] Added Shared Container Iterator adaptor to iterator adaptor library. [SVN r15169] --- shared_iterator_example1.cpp | 42 ++++++++++++++++++++++++++++++++++++ shared_iterator_example2.cpp | 42 ++++++++++++++++++++++++++++++++++++ shared_iterator_example3.cpp | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 shared_iterator_example1.cpp create mode 100644 shared_iterator_example2.cpp create mode 100644 shared_iterator_example3.cpp diff --git a/shared_iterator_example1.cpp b/shared_iterator_example1.cpp new file mode 100644 index 0000000..db7b511 --- /dev/null +++ b/shared_iterator_example1.cpp @@ -0,0 +1,42 @@ +// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and +// distribute this software is granted provided this copyright notice appears +// in all copies. This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. + +#include "boost/shared_container_iterator.hpp" +#include "boost/shared_ptr.hpp" +#include +#include +#include + +typedef boost::shared_container_iterator_generator< std::vector >::type + iterator; + + +void set_range(iterator& i, iterator& end) { + + boost::shared_ptr< std::vector > ints(new std::vector()); + + ints->push_back(0); + ints->push_back(1); + ints->push_back(2); + ints->push_back(3); + ints->push_back(4); + ints->push_back(5); + + i = iterator(ints->begin(),ints); + end = iterator(ints->end(),ints); +} + + +int main() { + + iterator i,end; + + set_range(i,end); + + std::copy(i,end,std::ostream_iterator(std::cout,",")); + std::cout.put('\n'); + + return 0; +} diff --git a/shared_iterator_example2.cpp b/shared_iterator_example2.cpp new file mode 100644 index 0000000..a1d16db --- /dev/null +++ b/shared_iterator_example2.cpp @@ -0,0 +1,42 @@ +// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and +// distribute this software is granted provided this copyright notice appears +// in all copies. This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. + +#include "boost/shared_container_iterator.hpp" +#include "boost/shared_ptr.hpp" +#include +#include +#include +#include + + +template +void print_range_nl (Iterator begin, Iterator end) { + typedef typename std::iterator_traits::value_type val; + std::copy(begin,end,std::ostream_iterator(std::cout,",")); + std::cout.put('\n'); +} + + +int main() { + + typedef boost::shared_ptr< std::vector > ints_t; + { + ints_t ints(new std::vector()); + + ints->push_back(0); + ints->push_back(1); + ints->push_back(2); + ints->push_back(3); + ints->push_back(4); + ints->push_back(5); + + print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints), + boost::make_shared_container_iterator(ints->end(),ints)); + } + + + + return 0; +} diff --git a/shared_iterator_example3.cpp b/shared_iterator_example3.cpp new file mode 100644 index 0000000..0e4887f --- /dev/null +++ b/shared_iterator_example3.cpp @@ -0,0 +1,41 @@ +// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and +// distribute this software is granted provided this copyright notice appears +// in all copies. This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. + +#include "boost/shared_container_iterator.hpp" +#include "boost/shared_ptr.hpp" +#include "boost/tuple/tuple.hpp" // for boost::tie +#include // for std::copy +#include +#include + + +typedef boost::shared_container_iterator_generator< std::vector >::type + function_iterator; + +std::pair +return_range() { + boost::shared_ptr< std::vector > range(new std::vector()); + range->push_back(0); + range->push_back(1); + range->push_back(2); + range->push_back(3); + range->push_back(4); + range->push_back(5); + return boost::make_shared_container_range(range); +} + + +int main() { + + + function_iterator i,end; + + boost::tie(i,end) = return_range(); + + std::copy(i,end,std::ostream_iterator(std::cout,",")); + std::cout.put('\n'); + + return 0; +} From fff85e7db931e57108e9e986e7398cb243927a9f Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Mon, 11 Aug 2003 16:29:47 +0000 Subject: [PATCH 02/12] Updated shared_container_iterator to use the new iterator adaptors library. Updated the documentation and examples as well to reflect the changes. [SVN r19535] --- shared_iterator_example1.cpp | 3 +-- shared_iterator_example3.cpp | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/shared_iterator_example1.cpp b/shared_iterator_example1.cpp index db7b511..a6a8235 100644 --- a/shared_iterator_example1.cpp +++ b/shared_iterator_example1.cpp @@ -9,8 +9,7 @@ #include #include -typedef boost::shared_container_iterator_generator< std::vector >::type - iterator; +typedef boost::shared_container_iterator< std::vector > iterator; void set_range(iterator& i, iterator& end) { diff --git a/shared_iterator_example3.cpp b/shared_iterator_example3.cpp index 0e4887f..9a492f8 100644 --- a/shared_iterator_example3.cpp +++ b/shared_iterator_example3.cpp @@ -11,10 +11,9 @@ #include -typedef boost::shared_container_iterator_generator< std::vector >::type - function_iterator; +typedef boost::shared_container_iterator< std::vector > iterator; -std::pair +std::pair return_range() { boost::shared_ptr< std::vector > range(new std::vector()); range->push_back(0); @@ -30,7 +29,7 @@ return_range() { int main() { - function_iterator i,end; + iterator i,end; boost::tie(i,end) = return_range(); From f86cd29f526edeb001cdc78c538a1f7dd2b5ad2c Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 26 Dec 2003 23:26:49 +0000 Subject: [PATCH 03/12] Fix tabs in file. [SVN r21399] --- shared_iterator_example2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared_iterator_example2.cpp b/shared_iterator_example2.cpp index a1d16db..10659f7 100644 --- a/shared_iterator_example2.cpp +++ b/shared_iterator_example2.cpp @@ -33,7 +33,7 @@ int main() { ints->push_back(5); print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints), - boost::make_shared_container_iterator(ints->end(),ints)); + boost::make_shared_container_iterator(ints->end(),ints)); } From 67ac9572736670df3d22661241de371469792d48 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Mon, 2 Feb 2004 22:16:36 +0000 Subject: [PATCH 04/12] shared_container_iterator library: - updated Copyright and License notices - Added shared_iterator_test to the iterator test suite. [SVN r22140] --- shared_iterator_example1.cpp | 9 +++++---- shared_iterator_example2.cpp | 9 +++++---- shared_iterator_example3.cpp | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/shared_iterator_example1.cpp b/shared_iterator_example1.cpp index a6a8235..f88e094 100644 --- a/shared_iterator_example1.cpp +++ b/shared_iterator_example1.cpp @@ -1,7 +1,8 @@ -// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears -// in all copies. This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Copyright 2003 The Trustees of Indiana University. + +// 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) #include "boost/shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" diff --git a/shared_iterator_example2.cpp b/shared_iterator_example2.cpp index 10659f7..a957707 100644 --- a/shared_iterator_example2.cpp +++ b/shared_iterator_example2.cpp @@ -1,7 +1,8 @@ -// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears -// in all copies. This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Copyright 2003 The Trustees of Indiana University. + +// 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) #include "boost/shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" diff --git a/shared_iterator_example3.cpp b/shared_iterator_example3.cpp index 9a492f8..5615d45 100644 --- a/shared_iterator_example3.cpp +++ b/shared_iterator_example3.cpp @@ -1,7 +1,8 @@ -// (C) Copyright Ronald Garcia 2002. Permission to copy, use, modify, sell and -// distribute this software is granted provided this copyright notice appears -// in all copies. This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Copyright 2003 The Trustees of Indiana University. + +// 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) #include "boost/shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" From 84227ea6ba2b651bc7dfd38d70bfd36f4896c9c2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Dec 2017 22:04:25 +0200 Subject: [PATCH 05/12] Move shared_iterator_example* to example/ --- .../shared_iterator_example1.cpp | 0 .../shared_iterator_example2.cpp | 0 .../shared_iterator_example3.cpp | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename shared_iterator_example1.cpp => example/shared_iterator_example1.cpp (100%) rename shared_iterator_example2.cpp => example/shared_iterator_example2.cpp (100%) rename shared_iterator_example3.cpp => example/shared_iterator_example3.cpp (100%) diff --git a/shared_iterator_example1.cpp b/example/shared_iterator_example1.cpp similarity index 100% rename from shared_iterator_example1.cpp rename to example/shared_iterator_example1.cpp diff --git a/shared_iterator_example2.cpp b/example/shared_iterator_example2.cpp similarity index 100% rename from shared_iterator_example2.cpp rename to example/shared_iterator_example2.cpp diff --git a/shared_iterator_example3.cpp b/example/shared_iterator_example3.cpp similarity index 100% rename from shared_iterator_example3.cpp rename to example/shared_iterator_example3.cpp From 91b392a478cf1b1b2c246a5d7ecb6ffc31456e60 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 29 May 2017 19:10:46 +0300 Subject: [PATCH 06/12] Move test files to test/ --- test/shared_iterator_test.cpp | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/shared_iterator_test.cpp diff --git a/test/shared_iterator_test.cpp b/test/shared_iterator_test.cpp new file mode 100644 index 0000000..ff5b9c6 --- /dev/null +++ b/test/shared_iterator_test.cpp @@ -0,0 +1,64 @@ +// Copyright 2003 The Trustees of Indiana University. + +// 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) + +// Shared container iterator adaptor +// Author: Ronald Garcia +// See http://boost.org/libs/utility/shared_container_iterator.html +// for documentation. + +// +// shared_iterator_test.cpp - Regression tests for shared_container_iterator. +// + + +#include "boost/shared_container_iterator.hpp" +#include "boost/shared_ptr.hpp" +#include +#include + +struct resource { + static int count; + resource() { ++count; } + resource(resource const&) { ++count; } + ~resource() { --count; } +}; +int resource::count = 0; + +typedef std::vector resources_t; + +typedef boost::shared_container_iterator< resources_t > iterator; + + +void set_range(iterator& i, iterator& end) { + + boost::shared_ptr< resources_t > objs(new resources_t()); + + for (int j = 0; j != 6; ++j) + objs->push_back(resource()); + + i = iterator(objs->begin(),objs); + end = iterator(objs->end(),objs); + assert(resource::count == 6); +} + + +int main() { + + assert(resource::count == 0); + + { + iterator i; + { + iterator end; + set_range(i,end); + assert(resource::count == 6); + } + assert(resource::count == 6); + } + assert(resource::count == 0); + + return 0; +} From affe7e6d84700accd1a5df0a2bec654e9c7ae49e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Dec 2017 23:45:33 +0200 Subject: [PATCH 07/12] Add shared_iterator_test to test/Jamfile --- test/Jamfile.v2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ac694e1..888a043 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,4 +59,6 @@ test-suite iterator [ run next_prior_test.cpp ] [ run advance_test.cpp ] [ run distance_test.cpp ] + + [ run shared_iterator_test.cpp ] ; From adecfd94f3e244f0dae856322bc16c77126ee9e9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Dec 2017 23:45:59 +0200 Subject: [PATCH 08/12] Use lightweight_test in shared_iterator_test.cpp --- test/shared_iterator_test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/shared_iterator_test.cpp b/test/shared_iterator_test.cpp index ff5b9c6..27e007a 100644 --- a/test/shared_iterator_test.cpp +++ b/test/shared_iterator_test.cpp @@ -16,8 +16,8 @@ #include "boost/shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" +#include #include -#include struct resource { static int count; @@ -41,24 +41,24 @@ void set_range(iterator& i, iterator& end) { i = iterator(objs->begin(),objs); end = iterator(objs->end(),objs); - assert(resource::count == 6); + BOOST_TEST_EQ(resource::count, 6); } int main() { - assert(resource::count == 0); + BOOST_TEST_EQ(resource::count, 0); { iterator i; { iterator end; set_range(i,end); - assert(resource::count == 6); + BOOST_TEST_EQ(resource::count, 6); } - assert(resource::count == 6); + BOOST_TEST_EQ(resource::count, 6); } - assert(resource::count == 0); + BOOST_TEST_EQ(resource::count, 0); - return 0; + return boost::report_errors(); } From 5ad48c4d14eacc1aaa915528a5397f1f0facce79 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 23 Dec 2017 23:54:33 +0200 Subject: [PATCH 09/12] Fix links to examples --- doc/quickbook/shared_container_iterator.qbk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/quickbook/shared_container_iterator.qbk b/doc/quickbook/shared_container_iterator.qbk index faf2301..d48658c 100644 --- a/doc/quickbook/shared_container_iterator.qbk +++ b/doc/quickbook/shared_container_iterator.qbk @@ -56,7 +56,7 @@ original shared pointer `ints` ceases to exist after `set_range()` returns, the `shared_counter_iterator` objects maintain references to the underlying vector and thereby extend the container's lifetime. -[@../../../libs/utility/shared_iterator_example1.cpp `shared_iterator_example1.cpp`]: +[@../../example/shared_iterator_example1.cpp `shared_iterator_example1.cpp`]: #include "shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" @@ -139,7 +139,7 @@ explicitly specifying its type. This example, similar to the previous, uses `make_shared_container_iterator()` to create the iterators. -[@../../../libs/utility/shared_iterator_example2.cpp `shared_iterator_example2.cpp`]: +[@../../example/shared_iterator_example2.cpp `shared_iterator_example2.cpp`]: #include "shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" @@ -200,7 +200,7 @@ named. The output from this example is the same as the previous. In the following example, a range of values is returned as a pair of shared_container_iterator objects. -[@../../../libs/utility/shared_iterator_example3.cpp `shared_iterator_example3.cpp`]: +[@../../example/shared_iterator_example3.cpp `shared_iterator_example3.cpp`]: #include "shared_container_iterator.hpp" #include "boost/shared_ptr.hpp" From 486721bbfe40e2d4140080c76e152915984fb80e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 24 Dec 2017 01:47:23 +0200 Subject: [PATCH 10/12] Update .travis.yml, appveyor.yml --- .travis.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++-------- appveyor.yml | 17 +++++++++---- 2 files changed, 69 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index bcc1a2f..c0e97f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# Copyright 2016 Peter Dimov +# Copyright 2016, 2017 Peter Dimov # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) @@ -8,18 +8,68 @@ sudo: false python: "2.7" -os: - - linux - - osx - branches: only: - master - develop + - /feature\/.*/ + +env: + matrix: + - BOGUS_JOB=true + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + compiler: g++ + env: TOOLSET=gcc CXXSTD=03,11 + + - os: linux + compiler: g++-5 + env: TOOLSET=gcc-5 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-6 + env: TOOLSET=gcc-6 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-7 + env: TOOLSET=gcc-7 CXXSTD=03,11,14,17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++ + env: TOOLSET=clang CXXSTD=03,11,14,1z + + - os: osx + compiler: clang++ + env: TOOLSET=clang CXXSTD=03,11,14,1z install: + - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true - cd .. - - git clone -b $TRAVIS_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root - cd boost-root - git submodule update --init tools/build - git submodule update --init libs/config @@ -30,10 +80,7 @@ install: - ./b2 headers script: - - TOOLSET=gcc,clang - - if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi - - ./b2 --verbose-test libs/config/test//config_info toolset=$TOOLSET || true - - ./b2 libs/iterator/test toolset=$TOOLSET + - ./b2 -j3 libs/iterator/test toolset=$TOOLSET cxxstd=$CXXSTD notifications: email: diff --git a/appveyor.yml b/appveyor.yml index e5ba002..b236d12 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,27 +10,34 @@ branches: only: - master - develop + - /feature\/.*/ environment: matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 + TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0,msvc-14.0 + TOOLSET: msvc-14.0 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 TOOLSET: msvc-14.1 + CXXSTD: 14,17 install: + - set BOOST_BRANCH=develop + - if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master - cd .. - - git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root + - git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root - cd boost-root - git submodule update --init tools/build - git submodule update --init libs/config - git submodule update --init tools/boostdep - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\iterator - python tools/boostdep/depinst/depinst.py iterator - - bootstrap - - b2 headers + - cmd /c bootstrap + - b2 -d0 headers build: off test_script: - - b2 libs/iterator/test toolset=%TOOLSET% + - if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% + - b2 -j3 libs/iterator/test toolset=%TOOLSET% %CXXSTD% From 386dbf10540a20a8b0b432ea09d693112e0934dd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 24 Dec 2017 04:38:07 +0200 Subject: [PATCH 11/12] Skip zip_iterator_test_std_pair on msvc-9.0 and below --- test/zip_iterator_test_std_pair.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/zip_iterator_test_std_pair.cpp b/test/zip_iterator_test_std_pair.cpp index 215777a..e714732 100644 --- a/test/zip_iterator_test_std_pair.cpp +++ b/test/zip_iterator_test_std_pair.cpp @@ -6,6 +6,20 @@ // // See http://www.boost.org for most recent version including documentation. +#include +#include +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1600) + +BOOST_PRAGMA_MESSAGE("Skipping test on msvc-9.0 and below") + +int main() +{ +} + +#else + #include #include @@ -14,3 +28,4 @@ #include "detail/zip_iterator_test.ipp" +#endif // #if BOOST_WORKAROUND From 0013c5c4f055a5a8add08ce7ff639513358f99b1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 24 Dec 2017 04:56:47 +0200 Subject: [PATCH 12/12] Skip zip_iterator_test_std_pair on g++ in C++03 mode --- test/zip_iterator_test_std_pair.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/zip_iterator_test_std_pair.cpp b/test/zip_iterator_test_std_pair.cpp index e714732..4353b6d 100644 --- a/test/zip_iterator_test_std_pair.cpp +++ b/test/zip_iterator_test_std_pair.cpp @@ -13,10 +13,12 @@ #if BOOST_WORKAROUND(BOOST_MSVC, < 1600) BOOST_PRAGMA_MESSAGE("Skipping test on msvc-9.0 and below") +int main() {} -int main() -{ -} +#elif defined(BOOST_GCC) && __cplusplus < 201100 + +BOOST_PRAGMA_MESSAGE("Skipping test on g++ in C++03 mode") +int main() {} #else @@ -28,4 +30,4 @@ int main() #include "detail/zip_iterator_test.ipp" -#endif // #if BOOST_WORKAROUND +#endif