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% 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" diff --git a/example/shared_iterator_example1.cpp b/example/shared_iterator_example1.cpp new file mode 100644 index 0000000..f88e094 --- /dev/null +++ b/example/shared_iterator_example1.cpp @@ -0,0 +1,42 @@ +// 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" +#include +#include +#include + +typedef boost::shared_container_iterator< std::vector > 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/example/shared_iterator_example2.cpp b/example/shared_iterator_example2.cpp new file mode 100644 index 0000000..a957707 --- /dev/null +++ b/example/shared_iterator_example2.cpp @@ -0,0 +1,43 @@ +// 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" +#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/example/shared_iterator_example3.cpp b/example/shared_iterator_example3.cpp new file mode 100644 index 0000000..5615d45 --- /dev/null +++ b/example/shared_iterator_example3.cpp @@ -0,0 +1,41 @@ +// 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" +#include "boost/tuple/tuple.hpp" // for boost::tie +#include // for std::copy +#include +#include + + +typedef boost::shared_container_iterator< std::vector > 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() { + + + iterator i,end; + + boost::tie(i,end) = return_range(); + + std::copy(i,end,std::ostream_iterator(std::cout,",")); + std::cout.put('\n'); + + return 0; +} 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 ] ; diff --git a/test/shared_iterator_test.cpp b/test/shared_iterator_test.cpp new file mode 100644 index 0000000..27e007a --- /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); + BOOST_TEST_EQ(resource::count, 6); +} + + +int main() { + + BOOST_TEST_EQ(resource::count, 0); + + { + iterator i; + { + iterator end; + set_range(i,end); + BOOST_TEST_EQ(resource::count, 6); + } + BOOST_TEST_EQ(resource::count, 6); + } + BOOST_TEST_EQ(resource::count, 0); + + return boost::report_errors(); +} diff --git a/test/zip_iterator_test_std_pair.cpp b/test/zip_iterator_test_std_pair.cpp index 215777a..4353b6d 100644 --- a/test/zip_iterator_test_std_pair.cpp +++ b/test/zip_iterator_test_std_pair.cpp @@ -6,6 +6,22 @@ // // 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() {} + +#elif defined(BOOST_GCC) && __cplusplus < 201100 + +BOOST_PRAGMA_MESSAGE("Skipping test on g++ in C++03 mode") +int main() {} + +#else + #include #include @@ -14,3 +30,4 @@ #include "detail/zip_iterator_test.ipp" +#endif