mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-11 13:33:56 +00:00
Merge branch 'develop' into fix/unwanted_adl
This commit is contained in:
commit
194087e8ca
73
.travis.yml
73
.travis.yml
@ -1,4 +1,4 @@
|
|||||||
# Copyright 2016 Peter Dimov
|
# Copyright 2016, 2017 Peter Dimov
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# 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)
|
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
@ -8,32 +8,79 @@ sudo: false
|
|||||||
|
|
||||||
python: "2.7"
|
python: "2.7"
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- develop
|
- 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:
|
install:
|
||||||
|
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||||
- cd ..
|
- 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
|
- cd boost-root
|
||||||
- git submodule update --init --depth 1 tools/build
|
- git submodule update --init tools/build
|
||||||
- git submodule update --init --depth 1 libs/config
|
- git submodule update --init libs/config
|
||||||
- git submodule update --init --depth 1 tools/boostdep
|
- git submodule update --init tools/boostdep
|
||||||
- cp -r $TRAVIS_BUILD_DIR/* libs/iterator
|
- cp -r $TRAVIS_BUILD_DIR/* libs/iterator
|
||||||
- python tools/boostdep/depinst/depinst.py iterator
|
- python tools/boostdep/depinst/depinst.py iterator
|
||||||
- ./bootstrap.sh
|
- ./bootstrap.sh
|
||||||
- ./b2 headers
|
- ./b2 headers
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- TOOLSET=gcc,clang
|
- ./b2 -j3 libs/iterator/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||||
- 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
|
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
43
appveyor.yml
Normal file
43
appveyor.yml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Copyright 2017 Edward Diener
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
version: 1.0.{build}-{branch}
|
||||||
|
|
||||||
|
shallow_clone: true
|
||||||
|
|
||||||
|
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-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 %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
|
||||||
|
- cmd /c bootstrap
|
||||||
|
- b2 -d0 headers
|
||||||
|
|
||||||
|
build: off
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||||
|
- b2 -j3 libs/iterator/test toolset=%TOOLSET% %CXXSTD%
|
@ -56,7 +56,7 @@ original shared pointer `ints` ceases to exist after `set_range()`
|
|||||||
returns, the `shared_counter_iterator` objects maintain references to
|
returns, the `shared_counter_iterator` objects maintain references to
|
||||||
the underlying vector and thereby extend the container's lifetime.
|
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 "shared_container_iterator.hpp"
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
@ -139,7 +139,7 @@ explicitly specifying its type.
|
|||||||
This example, similar to the previous,
|
This example, similar to the previous,
|
||||||
uses `make_shared_container_iterator()` to create the iterators.
|
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 "shared_container_iterator.hpp"
|
||||||
#include "boost/shared_ptr.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.
|
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 "shared_container_iterator.hpp"
|
||||||
#include "boost/shared_ptr.hpp"
|
#include "boost/shared_ptr.hpp"
|
||||||
|
@ -45,8 +45,7 @@ A non-generic implementation of ``zip_func`` could look as follows:
|
|||||||
::
|
::
|
||||||
|
|
||||||
|
|
||||||
struct zip_func :
|
struct zip_func
|
||||||
public std::unary_function<const boost::tuple<const double&, const int&>&, void>
|
|
||||||
{
|
{
|
||||||
void operator()(const boost::tuple<const double&, const int&>& t) const
|
void operator()(const boost::tuple<const double&, const int&>& t) const
|
||||||
{
|
{
|
||||||
|
42
example/shared_iterator_example1.cpp
Normal file
42
example/shared_iterator_example1.cpp
Normal 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;
|
||||||
|
}
|
43
example/shared_iterator_example2.cpp
Normal file
43
example/shared_iterator_example2.cpp
Normal 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;
|
||||||
|
}
|
41
example/shared_iterator_example3.cpp
Normal file
41
example/shared_iterator_example3.cpp
Normal 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;
|
||||||
|
}
|
@ -16,9 +16,10 @@
|
|||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
template <class Operation>
|
template <class Operation>
|
||||||
class binder1st
|
class binder1st {
|
||||||
: public std::unary_function<typename Operation::second_argument_type,
|
public:
|
||||||
typename Operation::result_type> {
|
typedef typename Operation::result_type result_type;
|
||||||
|
typedef typename Operation::second_argument_type argument_type;
|
||||||
protected:
|
protected:
|
||||||
Operation op;
|
Operation op;
|
||||||
typename Operation::first_argument_type value;
|
typename Operation::first_argument_type value;
|
||||||
@ -29,7 +30,7 @@ namespace boost {
|
|||||||
: op(x), value(y) {}
|
: op(x), value(y) {}
|
||||||
typename Operation::result_type
|
typename Operation::result_type
|
||||||
operator()(const typename Operation::second_argument_type& x) const {
|
operator()(const typename Operation::second_argument_type& x) const {
|
||||||
return op(value, x);
|
return op(value, x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,5 +73,3 @@ main(int, char*[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,15 +426,16 @@ namespace detail
|
|||||||
>::type iterator_category;
|
>::type iterator_category;
|
||||||
|
|
||||||
// Needed for some broken libraries (see below)
|
// Needed for some broken libraries (see below)
|
||||||
typedef boost::iterator<
|
struct workaround_iterator_base
|
||||||
iterator_category
|
{
|
||||||
, Value
|
typedef typename iterator_archetype_base::iterator_category iterator_category;
|
||||||
, typename traversal_archetype_base<
|
typedef Value value_type;
|
||||||
|
typedef typename traversal_archetype_base<
|
||||||
Value, AccessCategory, TraversalCategory
|
Value, AccessCategory, TraversalCategory
|
||||||
>::difference_type
|
>::difference_type difference_type;
|
||||||
, typename access::pointer
|
typedef typename access::pointer pointer;
|
||||||
, typename access::reference
|
typedef typename access::reference reference;
|
||||||
> workaround_iterator_base;
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,13 @@ struct new_random_access
|
|||||||
{};
|
{};
|
||||||
|
|
||||||
struct new_iterator
|
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; }
|
int& operator*() const { return *m_x; }
|
||||||
new_iterator& operator++() { return *this; }
|
new_iterator& operator++() { return *this; }
|
||||||
new_iterator operator++(int) { 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; }
|
new_iterator operator+(std::ptrdiff_t, new_iterator x) { return x; }
|
||||||
|
|
||||||
struct old_iterator
|
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; }
|
int& operator*() const { return *m_x; }
|
||||||
old_iterator& operator++() { return *this; }
|
old_iterator& operator++() { return *this; }
|
||||||
old_iterator operator++(int) { return *this; }
|
old_iterator operator++(int) { return *this; }
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <boost/concept_check.hpp>
|
#include <boost/concept_check.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
#include <boost/next_prior.hpp>
|
||||||
|
|
||||||
#include <boost/mpl/has_xxx.hpp>
|
#include <boost/mpl/has_xxx.hpp>
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstddef> // std::ptrdiff_t
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/iterator/is_lvalue_iterator.hpp>
|
#include <boost/iterator/is_lvalue_iterator.hpp>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
|
|
||||||
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
|
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#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;
|
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;
|
boost::noncopyable const& operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct proxy_iterator
|
struct proxy_iterator
|
||||||
: boost::iterator<std::output_iterator_tag,T>
|
|
||||||
{
|
{
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
typedef std::output_iterator_tag iterator_category;
|
||||||
#if BOOST_WORKAROUND(__GNUC__, == 2)
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef boost::iterator<std::input_iterator_tag,value_type> base;
|
typedef T* pointer;
|
||||||
typedef base::iterator_category iterator_category;
|
typedef T& reference;
|
||||||
typedef base::difference_type difference_type;
|
|
||||||
typedef base::pointer pointer;
|
|
||||||
typedef base::reference reference;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct proxy
|
struct proxy
|
||||||
{
|
{
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstddef> // std::ptrdiff_t
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/iterator/is_readable_iterator.hpp>
|
#include <boost/iterator/is_readable_iterator.hpp>
|
||||||
#include <boost/iterator.hpp>
|
|
||||||
|
|
||||||
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
|
// Last, for BOOST_NO_LVALUE_RETURN_DETECTION
|
||||||
#include <boost/iterator/detail/config_def.hpp>
|
#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;
|
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;
|
boost::noncopyable const& operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct proxy_iterator : boost::iterator<std::output_iterator_tag,v>
|
struct proxy_iterator
|
||||||
{
|
{
|
||||||
#if BOOST_WORKAROUND(__GNUC__, == 2)
|
typedef std::output_iterator_tag iterator_category;
|
||||||
typedef boost::iterator<std::input_iterator_tag,v> base;
|
typedef v value_type;
|
||||||
typedef base::iterator_category iterator_category;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef base::value_type value_type;
|
typedef v* pointer;
|
||||||
typedef base::difference_type difference_type;
|
typedef v& reference;
|
||||||
typedef base::pointer pointer;
|
|
||||||
typedef base::reference reference;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct proxy
|
struct proxy
|
||||||
{
|
{
|
||||||
@ -50,16 +59,13 @@ struct proxy_iterator : boost::iterator<std::output_iterator_tag,v>
|
|||||||
proxy operator*() const;
|
proxy operator*() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct proxy_iterator2 : boost::iterator<std::output_iterator_tag,v>
|
struct proxy_iterator2
|
||||||
{
|
{
|
||||||
#if BOOST_WORKAROUND(__GNUC__, == 2)
|
typedef std::output_iterator_tag iterator_category;
|
||||||
typedef boost::iterator<std::input_iterator_tag,v> base;
|
typedef v value_type;
|
||||||
typedef base::iterator_category iterator_category;
|
typedef std::ptrdiff_t difference_type;
|
||||||
typedef base::value_type value_type;
|
typedef v* pointer;
|
||||||
typedef base::difference_type difference_type;
|
typedef v& reference;
|
||||||
typedef base::pointer pointer;
|
|
||||||
typedef base::reference reference;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct proxy
|
struct proxy
|
||||||
{
|
{
|
||||||
|
64
test/shared_iterator_test.cpp
Normal file
64
test/shared_iterator_test.cpp
Normal 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();
|
||||||
|
}
|
@ -6,6 +6,22 @@
|
|||||||
//
|
//
|
||||||
// See http://www.boost.org for most recent version including documentation.
|
// 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 <utility>
|
||||||
#include <boost/fusion/adapted/std_pair.hpp>
|
#include <boost/fusion/adapted/std_pair.hpp>
|
||||||
|
|
||||||
@ -14,3 +30,4 @@
|
|||||||
|
|
||||||
#include "detail/zip_iterator_test.ipp"
|
#include "detail/zip_iterator_test.ipp"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user