Compare commits

..

32 Commits

Author SHA1 Message Date
Glen Fernandes
814965402e Merge pull request #49 from glenfe/develop
Use use_default from Boost.Core
2019-02-22 20:44:56 -05:00
Glen Fernandes
2af5a16539 Use use_default from Boost.Core
boost::use_default is now defined in Core for multiple Boost libraries.
2019-02-22 17:17:52 -05:00
Andrey Semashev
171c716d03 Enabled multiple git fetch jobs while executing depinst in CI. Increased the number of jobs to 8. 2019-01-15 13:54:52 +03:00
Andrey Semashev
398fe907d0 Use the actual number of logical CPUs for the number of CI build/test jobs. 2019-01-03 23:19:41 +03:00
Andrey Semashev
e31ae13df5 Re-added manual checkout of libs/config in CI as Boost.Build depends on it. 2018-12-20 20:46:10 +03:00
Andrey Semashev
02e74bf26a Use multiple jobs to checkout submodules in parallel in CI. 2018-12-18 22:34:58 +03:00
Andrey Semashev
20b5a9c11a Added tools/boost_install and libs/headers manual checkout to CI jobs. 2018-12-18 22:05:56 +03:00
Andrey Semashev
73918b8616 Added an experimental partial CMakeLists.txt for dependency tracking in CMake projects. 2018-12-18 19:49:23 +03:00
Andrey Semashev
bb1efd3370 Updated addressof.hpp include path. 2018-11-14 12:42:24 +03:00
Andrey Semashev
3cc4107d01 Added a test for compatibility of boost::distance between Range and Iterator.
This functionality is used in core Boost components, so it is preferable
to test it in Boost.Iterator, even if it's already tested in Boost.Range,
to discover problems as early as possible.

The test verifies that boost::distance implemented in Boost.Range can invoke
boost::distance in Boost.Iterator (i.e. the function lookup succeeds).
2018-09-23 12:37:21 +03:00
Andrey Semashev
6ab148be01 Revert "Revert "Replace using-declarations with using-directives to avoid ADL issues.""
This reverts commit 06875a754d.

The suggested fix for build failures need to be applied to Boost.Range:

https://github.com/boostorg/range/pull/75
2018-09-23 12:28:03 +03:00
Andrey Semashev
06875a754d Revert "Replace using-declarations with using-directives to avoid ADL issues."
This reverts commit 44cee00831.

The commit reportedly broke building Boost and quickbook.

b844c8df53 (commitcomment-30603668)
2018-09-22 18:46:36 +03:00
Andrey Semashev
b844c8df53 Merge pull request #44 from morinmorin/fix/unwanted_adl
Fix #43 (unwanted ADL issues)
2018-09-22 16:05:22 +03:00
morinmorin
194087e8ca Merge branch 'develop' into fix/unwanted_adl 2018-09-22 20:47:10 +09:00
morinmorin
b5edc8b64f Add test for ADL issues. 2018-09-22 20:44:29 +09:00
morinmorin
44cee00831 Replace using-declarations with using-directives to avoid ADL issues. 2018-09-22 20:20:59 +09:00
Edward Diener
b2adecb951 Merge pull request #40 from DanielaE/fix/no-iterator-inheritance
Inheriting std::iterator is deprecated in c++17.
2017-12-28 18:43:47 -05:00
Daniela Engert
e16f2de233 Inheriting std::iterator is deprecated in c++17.
Boost's iterator.hpp is deprecated, too. Therefore get rid of all of that and replace inheritance by lifting std::iterator's members into the derived class.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-12-27 09:32:51 +01:00
Peter Dimov
218dc4baf1 Merge branch 'feature/move-shared-iterator' into develop 2017-12-24 14:23:54 +02:00
Peter Dimov
0013c5c4f0 Skip zip_iterator_test_std_pair on g++ in C++03 mode 2017-12-24 04:56:47 +02:00
Peter Dimov
386dbf1054 Skip zip_iterator_test_std_pair on msvc-9.0 and below 2017-12-24 04:38:07 +02:00
Peter Dimov
486721bbfe Update .travis.yml, appveyor.yml 2017-12-24 01:47:23 +02:00
Peter Dimov
5ad48c4d14 Fix links to examples 2017-12-23 23:54:33 +02:00
Peter Dimov
adecfd94f3 Use lightweight_test in shared_iterator_test.cpp 2017-12-23 23:45:59 +02:00
Peter Dimov
affe7e6d84 Add shared_iterator_test to test/Jamfile 2017-12-23 23:45:33 +02:00
Peter Dimov
91b392a478 Move test files to test/ 2017-12-23 22:05:35 +02:00
Peter Dimov
84227ea6ba Move shared_iterator_example* to example/ 2017-12-23 22:04:25 +02:00
Ronald Garcia
67ac957273 shared_container_iterator library: - updated Copyright and License notices - Added shared_iterator_test to the iterator test suite.
[SVN r22140]
2017-12-23 22:02:20 +02:00
Rene Rivera
f86cd29f52 Fix tabs in file.
[SVN r21399]
2017-12-23 22:02:20 +02:00
Ronald Garcia
fff85e7db9 Updated shared_container_iterator to use the new iterator adaptors library. Updated the documentation and examples as well to reflect the changes.
[SVN r19535]
2017-12-23 22:02:20 +02:00
Ronald Garcia
d6c6f0ce16 Added Shared Container Iterator adaptor to iterator adaptor library.
[SVN r15169]
2017-12-23 22:02:20 +02:00
Peter Dimov
81faa161cf Add #include <boost/next_prior.hpp>; no longer in utility.hpp 2017-12-02 04:04:32 +02:00
22 changed files with 459 additions and 77 deletions

View File

@@ -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,32 +8,85 @@ 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:
- GIT_FETCH_JOBS=8
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- 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
- git submodule update --init tools/boostdep
- git submodule init tools/build
- git submodule init tools/boostdep
- git submodule init tools/boost_install
- git submodule init libs/headers
- git submodule init libs/config
- git submodule update --jobs $GIT_FETCH_JOBS
- cp -r $TRAVIS_BUILD_DIR/* libs/iterator
- python tools/boostdep/depinst/depinst.py iterator
- python tools/boostdep/depinst/depinst.py --git_args "--jobs $GIT_FETCH_JOBS" iterator
- ./bootstrap.sh
- ./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
- BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
- ./b2 -j $BUILD_JOBS libs/iterator/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:

34
CMakeLists.txt Normal file
View File

@@ -0,0 +1,34 @@
# Copyright 2018 Peter Dimov
# Copyright 2018 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet.
cmake_minimum_required(VERSION 3.5)
project(BoostIterator LANGUAGES CXX)
add_library(boost_iterator INTERFACE)
add_library(Boost::iterator ALIAS boost_iterator)
target_include_directories(boost_iterator INTERFACE include)
target_link_libraries(boost_iterator
INTERFACE
Boost::assert
Boost::concept_check
Boost::config
Boost::conversion
Boost::core
Boost::detail
Boost::function_types
Boost::fusion
Boost::mpl
Boost::optional
Boost::smart_ptr
Boost::static_assert
Boost::type_traits
Boost::utility
)

View File

@@ -10,27 +10,38 @@ 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 GIT_FETCH_JOBS=8
- 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
- git submodule init tools/build
- git submodule init tools/boostdep
- git submodule init tools/boost_install
- git submodule init libs/headers
- git submodule init libs/config
- git submodule update --jobs %GIT_FETCH_JOBS%
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\iterator
- python tools/boostdep/depinst/depinst.py iterator
- bootstrap
- b2 headers
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" iterator
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- b2 libs/iterator/test toolset=%TOOLSET%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/iterator/test toolset=%TOOLSET% %CXXSTD%

View File

@@ -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"

View File

@@ -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 <algorithm>
#include <iostream>
#include <vector>
typedef boost::shared_container_iterator< std::vector<int> > iterator;
void set_range(iterator& i, iterator& end) {
boost::shared_ptr< std::vector<int> > ints(new std::vector<int>());
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<int>(std::cout,","));
std::cout.put('\n');
return 0;
}

View File

@@ -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 <algorithm>
#include <iterator>
#include <iostream>
#include <vector>
template <typename Iterator>
void print_range_nl (Iterator begin, Iterator end) {
typedef typename std::iterator_traits<Iterator>::value_type val;
std::copy(begin,end,std::ostream_iterator<val>(std::cout,","));
std::cout.put('\n');
}
int main() {
typedef boost::shared_ptr< std::vector<int> > ints_t;
{
ints_t ints(new std::vector<int>());
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;
}

View File

@@ -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 <algorithm> // for std::copy
#include <iostream>
#include <vector>
typedef boost::shared_container_iterator< std::vector<int> > iterator;
std::pair<iterator,iterator>
return_range() {
boost::shared_ptr< std::vector<int> > range(new std::vector<int>());
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<int>(std::cout,","));
std::cout.put('\n');
return 0;
}

View File

@@ -77,7 +77,7 @@ namespace iterators {
} // namespace iterators
using iterators::advance;
using namespace iterators::advance_adl_barrier;
} // namespace boost

View File

@@ -4,6 +4,8 @@
#ifndef FACADE_ITERATOR_CATEGORY_DWA20031118_HPP
# define FACADE_ITERATOR_CATEGORY_DWA20031118_HPP
# include <boost/core/use_default.hpp>
# include <boost/iterator/iterator_categories.hpp>
# include <boost/mpl/or.hpp> // used in iterator_tag inheritance logic
@@ -33,8 +35,7 @@
namespace boost {
namespace iterators {
// forward declaration
struct use_default;
using boost::use_default;
namespace detail {

View File

@@ -58,7 +58,7 @@ namespace iterators {
} // namespace iterators
using iterators::distance;
using namespace iterators::distance_adl_barrier;
} // namespace boost

View File

@@ -9,6 +9,8 @@
#include <boost/static_assert.hpp>
#include <boost/core/use_default.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/detail/enable_if.hpp>
@@ -35,12 +37,10 @@ namespace iterators {
// Used as a default template argument internally, merely to
// indicate "use the default", this can also be passed by users
// explicitly in order to specify that the default should be used.
struct use_default;
using boost::use_default;
} // namespace iterators
using iterators::use_default;
// the incompleteness of use_default causes massive problems for
// is_convertible (naturally). This workaround is fortunately not
// needed for vc6/vc7.

View File

@@ -426,15 +426,16 @@ namespace detail
>::type iterator_category;
// Needed for some broken libraries (see below)
typedef boost::iterator<
iterator_category
, Value
, typename traversal_archetype_base<
struct workaround_iterator_base
{
typedef typename iterator_archetype_base::iterator_category iterator_category;
typedef Value value_type;
typedef typename traversal_archetype_base<
Value, AccessCategory, TraversalCategory
>::difference_type
, typename access::pointer
, typename access::reference
> workaround_iterator_base;
>::difference_type difference_type;
typedef typename access::pointer pointer;
typedef typename access::reference reference;
};
};
}

View File

@@ -16,7 +16,7 @@
#include <boost/iterator/detail/enable_if.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/core/addressof.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_const.hpp>

View File

@@ -59,4 +59,8 @@ test-suite iterator
[ run next_prior_test.cpp ]
[ run advance_test.cpp ]
[ run distance_test.cpp ]
[ compile adl_test.cpp ]
[ compile range_distance_compat_test.cpp ]
[ run shared_iterator_test.cpp ]
;

25
test/adl_test.cpp Normal file
View File

@@ -0,0 +1,25 @@
// Copyright (C) 2017 Michel Morin.
//
// Distributed under 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 <vector>
#include <boost/array.hpp>
#include <boost/iterator/advance.hpp>
#include <boost/iterator/distance.hpp>
int main()
{
// Test that boost::advance/distance are not found by ADL.
// (https://github.com/boostorg/iterator/issues/43)
typedef boost::array<int, 1> boost_type;
std::vector<boost_type> std_boost(2);
std::vector<boost_type>::iterator it = std_boost.begin();
advance(it, 2);
(void)distance(it, it);
return 0;
}

View File

@@ -16,8 +16,13 @@ struct new_random_access
{};
struct new_iterator
: public std::iterator< new_random_access, int >
{
typedef new_random_access iterator_category;
typedef int value_type;
typedef std::ptrdiff_t difference_type;
typedef int* pointer;
typedef int& reference;
int& operator*() const { return *m_x; }
new_iterator& operator++() { return *this; }
new_iterator operator++(int) { return *this; }
@@ -36,8 +41,13 @@ struct new_iterator
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
struct old_iterator
: public std::iterator<std::random_access_iterator_tag, int>
{
typedef std::random_access_iterator_tag iterator_category;
typedef int value_type;
typedef std::ptrdiff_t difference_type;
typedef int* pointer;
typedef int& reference;
int& operator*() const { return *m_x; }
old_iterator& operator++() { return *this; }
old_iterator operator++(int) { return *this; }

View File

@@ -24,6 +24,7 @@
#include <boost/concept_check.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/next_prior.hpp>
#include <boost/mpl/has_xxx.hpp>

View File

@@ -5,10 +5,10 @@
#include <deque>
#include <iterator>
#include <iostream>
#include <cstddef> // std::ptrdiff_t
#include <boost/static_assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/iterator/is_lvalue_iterator.hpp>
#include <boost/iterator.hpp>
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
#include <boost/iterator/detail/config_def.hpp>
@@ -20,29 +20,36 @@ struct v
};
struct value_iterator : boost::iterator<std::input_iterator_tag,v>
struct value_iterator
{
typedef std::input_iterator_tag iterator_category;
typedef v value_type;
typedef std::ptrdiff_t difference_type;
typedef v* pointer;
typedef v& reference;
v operator*() const;
};
struct noncopyable_iterator : boost::iterator<std::forward_iterator_tag,boost::noncopyable>
struct noncopyable_iterator
{
typedef std::forward_iterator_tag iterator_category;
typedef boost::noncopyable value_type;
typedef std::ptrdiff_t difference_type;
typedef boost::noncopyable* pointer;
typedef boost::noncopyable& reference;
boost::noncopyable const& operator*() const;
};
template <class T>
struct proxy_iterator
: boost::iterator<std::output_iterator_tag,T>
{
typedef T value_type;
#if BOOST_WORKAROUND(__GNUC__, == 2)
typedef boost::iterator<std::input_iterator_tag,value_type> base;
typedef base::iterator_category iterator_category;
typedef base::difference_type difference_type;
typedef base::pointer pointer;
typedef base::reference reference;
#endif
typedef std::output_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;
struct proxy
{

View File

@@ -5,10 +5,10 @@
#include <deque>
#include <iterator>
#include <iostream>
#include <cstddef> // std::ptrdiff_t
#include <boost/static_assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/iterator/is_readable_iterator.hpp>
#include <boost/iterator.hpp>
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
#include <boost/iterator/detail/config_def.hpp>
@@ -20,26 +20,35 @@ struct v
};
struct value_iterator : boost::iterator<std::input_iterator_tag,v>
struct value_iterator
{
typedef std::input_iterator_tag iterator_category;
typedef v value_type;
typedef std::ptrdiff_t difference_type;
typedef v* pointer;
typedef v& reference;
v operator*() const;
};
struct noncopyable_iterator : boost::iterator<std::forward_iterator_tag,boost::noncopyable>
struct noncopyable_iterator
{
typedef std::forward_iterator_tag iterator_category;
typedef boost::noncopyable value_type;
typedef std::ptrdiff_t difference_type;
typedef boost::noncopyable* pointer;
typedef boost::noncopyable& reference;
boost::noncopyable const& operator*() const;
};
struct proxy_iterator : boost::iterator<std::output_iterator_tag,v>
struct proxy_iterator
{
#if BOOST_WORKAROUND(__GNUC__, == 2)
typedef boost::iterator<std::input_iterator_tag,v> base;
typedef base::iterator_category iterator_category;
typedef base::value_type value_type;
typedef base::difference_type difference_type;
typedef base::pointer pointer;
typedef base::reference reference;
#endif
typedef std::output_iterator_tag iterator_category;
typedef v value_type;
typedef std::ptrdiff_t difference_type;
typedef v* pointer;
typedef v& reference;
struct proxy
{
@@ -50,16 +59,13 @@ struct proxy_iterator : boost::iterator<std::output_iterator_tag,v>
proxy operator*() const;
};
struct proxy_iterator2 : boost::iterator<std::output_iterator_tag,v>
struct proxy_iterator2
{
#if BOOST_WORKAROUND(__GNUC__, == 2)
typedef boost::iterator<std::input_iterator_tag,v> base;
typedef base::iterator_category iterator_category;
typedef base::value_type value_type;
typedef base::difference_type difference_type;
typedef base::pointer pointer;
typedef base::reference reference;
#endif
typedef std::output_iterator_tag iterator_category;
typedef v value_type;
typedef std::ptrdiff_t difference_type;
typedef v* pointer;
typedef v& reference;
struct proxy
{

View File

@@ -0,0 +1,22 @@
// Copyright (C) 2018 Andrey Semashev
//
// Distributed under 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/range/distance.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/iterator/distance.hpp>
int main()
{
// Test that boost::distance from Boost.Range works with boost::distance from Boost.Iterator
// (https://github.com/boostorg/iterator/commit/b844c8df530c474ec1856870b9b0de5f487b84d4#commitcomment-30603668)
typedef boost::iterator_range<const char*> range_type;
range_type range;
(void)boost::distance(range);
return 0;
}

View File

@@ -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 <boost/core/lightweight_test.hpp>
#include <vector>
struct resource {
static int count;
resource() { ++count; }
resource(resource const&) { ++count; }
~resource() { --count; }
};
int resource::count = 0;
typedef std::vector<resource> 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();
}

View File

@@ -6,6 +6,22 @@
//
// See http://www.boost.org for most recent version including documentation.
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/config/pragma_message.hpp>
#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 <utility>
#include <boost/fusion/adapted/std_pair.hpp>
@@ -14,3 +30,4 @@
#include "detail/zip_iterator_test.ipp"
#endif