mirror of
https://github.com/boostorg/iterator.git
synced 2025-06-26 20:41:35 +02:00
Compare commits
17 Commits
boost-1.51
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
a9b594c925 | |||
251b9f8057 | |||
2786268510 | |||
6bb82230b9 | |||
c07f55ff65 | |||
ac522bc9e1 | |||
4c60e26bf8 | |||
d11c7a3ec4 | |||
76fd8e27fb | |||
f2433c63d5 | |||
55c08b706c | |||
835498603d | |||
b0ec5a759b | |||
e06c4b3279 | |||
bf7d904bf8 | |||
efecbd0d27 | |||
65e229fb0d |
@ -13,7 +13,6 @@ boostbook standalone
|
||||
:
|
||||
iterator
|
||||
:
|
||||
<xsl:param>boost.root=../../../..
|
||||
<xsl:param>toc.max.depth=3
|
||||
<xsl:param>toc.section.depth=3
|
||||
<xsl:param>chunk.section.depth=4
|
||||
|
@ -99,7 +99,7 @@ private:
|
||||
</pre>
|
||||
<p>If <tt class="docutils literal"><span class="pre">Reference</span></tt> is <tt class="docutils literal"><span class="pre">use_default</span></tt> then the <tt class="docutils literal"><span class="pre">reference</span></tt> member of
|
||||
<tt class="docutils literal"><span class="pre">transform_iterator</span></tt> is
|
||||
<tt class="docutils literal"><span class="pre">result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type</span></tt>.
|
||||
<tt class="docutils literal"><span class="pre">result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type</span></tt>.
|
||||
Otherwise, <tt class="docutils literal"><span class="pre">reference</span></tt> is <tt class="docutils literal"><span class="pre">Reference</span></tt>.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre">Value</span></tt> is <tt class="docutils literal"><span class="pre">use_default</span></tt> then the <tt class="docutils literal"><span class="pre">value_type</span></tt> member is
|
||||
<tt class="docutils literal"><span class="pre">remove_cv<remove_reference<reference></span> <span class="pre">>::type</span></tt>. Otherwise,
|
||||
@ -117,10 +117,10 @@ convertible to <tt class="docutils literal"><span class="pre">input_iterator_tag
|
||||
<div class="section" id="transform-iterator-requirements">
|
||||
<h1><a class="toc-backref" href="#id3"><tt class="docutils literal"><span class="pre">transform_iterator</span></tt> requirements</a></h1>
|
||||
<p>The type <tt class="docutils literal"><span class="pre">UnaryFunction</span></tt> must be Assignable, Copy Constructible, and
|
||||
the expression <tt class="docutils literal"><span class="pre">f(*i)</span></tt> must be valid where <tt class="docutils literal"><span class="pre">f</span></tt> is a const object of
|
||||
the expression <tt class="docutils literal"><span class="pre">f(*i)</span></tt> must be valid where <tt class="docutils literal"><span class="pre">f</span></tt> is an object of
|
||||
type <tt class="docutils literal"><span class="pre">UnaryFunction</span></tt>, <tt class="docutils literal"><span class="pre">i</span></tt> is an object of type <tt class="docutils literal"><span class="pre">Iterator</span></tt>, and
|
||||
where the type of <tt class="docutils literal"><span class="pre">f(*i)</span></tt> must be
|
||||
<tt class="docutils literal"><span class="pre">result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type</span></tt>.</p>
|
||||
<tt class="docutils literal"><span class="pre">result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type</span></tt>.</p>
|
||||
<p>The argument <tt class="docutils literal"><span class="pre">Iterator</span></tt> shall model Readable Iterator.</p>
|
||||
</div>
|
||||
<div class="section" id="transform-iterator-models">
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
If ``Reference`` is ``use_default`` then the ``reference`` member of
|
||||
``transform_iterator`` is
|
||||
``result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type``.
|
||||
``result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type``.
|
||||
Otherwise, ``reference`` is ``Reference``.
|
||||
|
||||
If ``Value`` is ``use_default`` then the ``value_type`` member is
|
||||
@ -64,10 +64,10 @@ convertible to ``input_iterator_tag``.
|
||||
...................................
|
||||
|
||||
The type ``UnaryFunction`` must be Assignable, Copy Constructible, and
|
||||
the expression ``f(*i)`` must be valid where ``f`` is a const object of
|
||||
the expression ``f(*i)`` must be valid where ``f`` is an object of
|
||||
type ``UnaryFunction``, ``i`` is an object of type ``Iterator``, and
|
||||
where the type of ``f(*i)`` must be
|
||||
``result_of<const UnaryFunction(iterator_traits<Iterator>::reference)>::type``.
|
||||
``result_of<UnaryFunction(iterator_traits<Iterator>::reference)>::type``.
|
||||
|
||||
The argument ``Iterator`` shall model Readable Iterator.
|
||||
|
||||
|
@ -7,29 +7,23 @@
|
||||
#ifndef BOOST_FUNCTION_INPUT_ITERATOR
|
||||
#define BOOST_FUNCTION_INPUT_ITERATOR
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/function_types/is_function_pointer.hpp>
|
||||
#include <boost/function_types/is_function_reference.hpp>
|
||||
#include <boost/function_types/result_type.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace impl {
|
||||
|
||||
template <class Function, class Input>
|
||||
template <class Function, class Input>
|
||||
class function_input_iterator
|
||||
: public iterator_facade<
|
||||
: public iterator_facade<
|
||||
function_input_iterator<Function, Input>,
|
||||
typename Function::result_type,
|
||||
single_pass_traversal_tag,
|
||||
typename Function::result_type const &
|
||||
>
|
||||
{
|
||||
{
|
||||
public:
|
||||
function_input_iterator() {}
|
||||
function_input_iterator(Function & f_, Input state_ = Input())
|
||||
: f(&f_), state(state_), value((*f)()) {}
|
||||
function_input_iterator(Function * f_, Input state_ = Input())
|
||||
: f(f_), state(state_), value((*f)()) {}
|
||||
|
||||
void increment() {
|
||||
value = (*f)();
|
||||
@ -37,8 +31,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
typename Function::result_type const &
|
||||
dereference() const {
|
||||
return value;
|
||||
dereference() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool equal(function_input_iterator const & other) const {
|
||||
@ -49,93 +43,13 @@ namespace boost {
|
||||
Function * f;
|
||||
Input state;
|
||||
typename Function::result_type value;
|
||||
};
|
||||
|
||||
template <class Function, class Input>
|
||||
class function_pointer_input_iterator
|
||||
: public iterator_facade<
|
||||
function_pointer_input_iterator<Function, Input>,
|
||||
typename function_types::result_type<Function>::type,
|
||||
single_pass_traversal_tag,
|
||||
typename function_types::result_type<Function>::type const &
|
||||
>
|
||||
{
|
||||
public:
|
||||
function_pointer_input_iterator() {}
|
||||
function_pointer_input_iterator(Function &f_, Input state_ = Input())
|
||||
: f(f_), state(state_), value((*f)())
|
||||
{}
|
||||
|
||||
void increment() {
|
||||
value = (*f)();
|
||||
++state;
|
||||
}
|
||||
|
||||
typename function_types::result_type<Function>::type const &
|
||||
dereference() const {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool equal(function_pointer_input_iterator const & other) const {
|
||||
return f == other.f && state == other.state;
|
||||
}
|
||||
|
||||
private:
|
||||
Function f;
|
||||
Input state;
|
||||
typename function_types::result_type<Function>::type value;
|
||||
};
|
||||
|
||||
template <class Function, class Input>
|
||||
class function_reference_input_iterator
|
||||
: public function_pointer_input_iterator<Function*,Input>
|
||||
{
|
||||
public:
|
||||
function_reference_input_iterator(Function & f_, Input state_ = Input())
|
||||
: function_pointer_input_iterator<Function*,Input>(&f_, state_)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace impl
|
||||
|
||||
template <class Function, class Input>
|
||||
class function_input_iterator
|
||||
: public mpl::if_<
|
||||
function_types::is_function_pointer<Function>,
|
||||
impl::function_pointer_input_iterator<Function,Input>,
|
||||
typename mpl::if_<
|
||||
function_types::is_function_reference<Function>,
|
||||
impl::function_reference_input_iterator<Function,Input>,
|
||||
impl::function_input_iterator<Function,Input>
|
||||
>::type
|
||||
>::type
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
function_types::is_function_pointer<Function>,
|
||||
impl::function_pointer_input_iterator<Function,Input>,
|
||||
typename mpl::if_<
|
||||
function_types::is_function_reference<Function>,
|
||||
impl::function_reference_input_iterator<Function,Input>,
|
||||
impl::function_input_iterator<Function,Input>
|
||||
>::type
|
||||
>::type base_type;
|
||||
public:
|
||||
function_input_iterator(Function & f, Input i)
|
||||
: base_type(f, i) {}
|
||||
};
|
||||
|
||||
template <class Function, class Input>
|
||||
inline function_input_iterator<Function, Input>
|
||||
make_function_input_iterator(Function & f, Input state) {
|
||||
typedef function_input_iterator<Function, Input> result_t;
|
||||
return result_t(f, state);
|
||||
}
|
||||
|
||||
template <class Function, class Input>
|
||||
inline function_input_iterator<Function*, Input>
|
||||
make_function_input_iterator(Function * f, Input state) {
|
||||
typedef function_input_iterator<Function*, Input> result_t;
|
||||
return result_t(f, state);
|
||||
make_function_input_iterator(Function & f, Input state) {
|
||||
typedef function_input_iterator<Function, Input> result_t;
|
||||
return result_t(&f, state);
|
||||
}
|
||||
|
||||
struct infinite {
|
||||
|
@ -24,9 +24,15 @@
|
||||
|
||||
#ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
|
||||
# include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
# if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
|
||||
# include <boost/type_traits/add_reference.hpp>
|
||||
# endif
|
||||
|
||||
#else
|
||||
# include <boost/type_traits/add_reference.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/iterator/detail/config_def.hpp>
|
||||
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include <boost/iterator/detail/facade_iterator_category.hpp>
|
||||
#include <boost/iterator/detail/enable_if.hpp>
|
||||
|
||||
#include <boost/implicit_cast.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
@ -294,43 +294,46 @@ namespace boost
|
||||
|
||||
// operator->() needs special support for input iterators to strictly meet the
|
||||
// standard's requirements. If *i is not a reference type, we must still
|
||||
// produce a lvalue to which a pointer can be formed. We do that by
|
||||
// returning a proxy object containing an instance of the reference object.
|
||||
template <class Reference, class Pointer>
|
||||
struct operator_arrow_dispatch // proxy references
|
||||
// produce a lvalue to which a pointer can be formed. We do that by
|
||||
// returning an instantiation of this special proxy class template.
|
||||
template <class T>
|
||||
struct operator_arrow_proxy
|
||||
{
|
||||
struct proxy
|
||||
{
|
||||
explicit proxy(Reference const & x) : m_ref(x) {}
|
||||
Reference* operator->() { return boost::addressof(m_ref); }
|
||||
// This function is needed for MWCW and BCC, which won't call
|
||||
// operator-> again automatically per 13.3.1.2 para 8
|
||||
operator Reference*() { return boost::addressof(m_ref); }
|
||||
Reference m_ref;
|
||||
};
|
||||
typedef proxy result_type;
|
||||
static result_type apply(Reference const & x)
|
||||
{
|
||||
return result_type(x);
|
||||
}
|
||||
operator_arrow_proxy(T const* px) : m_value(*px) {}
|
||||
T* operator->() const { return &m_value; }
|
||||
// This function is needed for MWCW and BCC, which won't call operator->
|
||||
// again automatically per 13.3.1.2 para 8
|
||||
operator T*() const { return &m_value; }
|
||||
mutable T m_value;
|
||||
};
|
||||
|
||||
template <class T, class Pointer>
|
||||
struct operator_arrow_dispatch<T&, Pointer> // "real" references
|
||||
// A metafunction that gets the result type for operator->. Also
|
||||
// has a static function make() which builds the result from a
|
||||
// Reference
|
||||
template <class ValueType, class Reference, class Pointer>
|
||||
struct operator_arrow_result
|
||||
{
|
||||
typedef Pointer result_type;
|
||||
static result_type apply(T& x)
|
||||
// CWPro8.3 won't accept "operator_arrow_result::type", and we
|
||||
// need that type below, so metafunction forwarding would be a
|
||||
// losing proposition here.
|
||||
typedef typename mpl::if_<
|
||||
is_reference<Reference>
|
||||
, Pointer
|
||||
, operator_arrow_proxy<ValueType>
|
||||
>::type type;
|
||||
|
||||
static type make(Reference x)
|
||||
{
|
||||
return boost::addressof(x);
|
||||
return implicit_cast<type>(&x);
|
||||
}
|
||||
};
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// Deal with ETI
|
||||
template<>
|
||||
struct operator_arrow_dispatch<int, int>
|
||||
struct operator_arrow_result<int, int, int>
|
||||
{
|
||||
typedef int result_type;
|
||||
typedef int type;
|
||||
};
|
||||
# endif
|
||||
|
||||
@ -615,10 +618,11 @@ namespace boost
|
||||
Value, CategoryOrTraversal, Reference, Difference
|
||||
> associated_types;
|
||||
|
||||
typedef boost::detail::operator_arrow_dispatch<
|
||||
Reference
|
||||
typedef boost::detail::operator_arrow_result<
|
||||
typename associated_types::value_type
|
||||
, Reference
|
||||
, typename associated_types::pointer
|
||||
> operator_arrow_dispatch_;
|
||||
> pointer_;
|
||||
|
||||
protected:
|
||||
// For use by derived classes
|
||||
@ -630,7 +634,7 @@ namespace boost
|
||||
typedef Reference reference;
|
||||
typedef Difference difference_type;
|
||||
|
||||
typedef typename operator_arrow_dispatch_::result_type pointer;
|
||||
typedef typename pointer_::type pointer;
|
||||
|
||||
typedef typename associated_types::iterator_category iterator_category;
|
||||
|
||||
@ -641,7 +645,7 @@ namespace boost
|
||||
|
||||
pointer operator->() const
|
||||
{
|
||||
return operator_arrow_dispatch_::apply(*this->derived());
|
||||
return pointer_::make(*this->derived());
|
||||
}
|
||||
|
||||
typename boost::detail::operator_brackets_result<Derived,Value,reference>::type
|
||||
|
@ -42,11 +42,13 @@ namespace boost
|
||||
struct transform_iterator_base
|
||||
{
|
||||
private:
|
||||
typedef typename std::iterator_traits<Iterator>::reference Arg1;
|
||||
|
||||
// By default, dereferencing the iterator yields the same as
|
||||
// the function.
|
||||
typedef typename ia_dflt_help<
|
||||
Reference
|
||||
, result_of<const UnaryFunc(typename std::iterator_traits<Iterator>::reference)>
|
||||
, result_of<UnaryFunc(typename std::iterator_traits<Iterator>::value_type)>
|
||||
>::type reference;
|
||||
|
||||
// To get the default for Value: remove any reference on the
|
||||
|
59
include/boost/pending/integer_range.hpp
Normal file
59
include/boost/pending/integer_range.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
// (C) Copyright David Abrahams and Jeremy Siek 2000-2001.
|
||||
// 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)
|
||||
//
|
||||
// Revision History:
|
||||
// 04 Jan 2001 Factored counting_iterator stuff into
|
||||
// boost/counting_iterator.hpp (David Abrahams)
|
||||
|
||||
#ifndef BOOST_INTEGER_RANGE_HPP_
|
||||
#define BOOST_INTEGER_RANGE_HPP_
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/iterator/counting_iterator.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//=============================================================================
|
||||
// Counting Iterator and Integer Range Class
|
||||
|
||||
template <class IntegerType>
|
||||
struct integer_range {
|
||||
typedef counting_iterator<IntegerType> iterator;
|
||||
|
||||
typedef iterator const_iterator;
|
||||
typedef IntegerType value_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef IntegerType reference;
|
||||
typedef IntegerType const_reference;
|
||||
typedef const IntegerType* pointer;
|
||||
typedef const IntegerType* const_pointer;
|
||||
typedef IntegerType size_type;
|
||||
|
||||
integer_range(IntegerType start, IntegerType finish)
|
||||
: m_start(start), m_finish(finish) { }
|
||||
|
||||
iterator begin() const { return iterator(m_start); }
|
||||
iterator end() const { return iterator(m_finish); }
|
||||
size_type size() const { return m_finish - m_start; }
|
||||
bool empty() const { return m_finish == m_start; }
|
||||
void swap(integer_range& x) {
|
||||
std::swap(m_start, x.m_start);
|
||||
std::swap(m_finish, x.m_finish);
|
||||
}
|
||||
protected:
|
||||
IntegerType m_start, m_finish;
|
||||
};
|
||||
|
||||
template <class IntegerType>
|
||||
inline integer_range<IntegerType>
|
||||
make_integer_range(IntegerType first, IntegerType last)
|
||||
{
|
||||
return integer_range<IntegerType>(first, last);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_INTEGER_RANGE_HPP_
|
@ -43,6 +43,5 @@ test-suite iterator
|
||||
[ run iterator_traits_test.cpp ]
|
||||
[ run permutation_iterator_test.cpp : : : # <stlport-iostream>on
|
||||
]
|
||||
[ run function_input_iterator_test.cpp ]
|
||||
|
||||
;
|
||||
|
@ -1,70 +0,0 @@
|
||||
// Copyright 2010 (c) Dean Michael Berris
|
||||
// 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/iterator/function_input_iterator.hpp>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
struct ones {
|
||||
typedef int result_type;
|
||||
result_type operator() () {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
int ones_function () {
|
||||
return 1;
|
||||
}
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
// test the iterator with function objects
|
||||
ones ones_generator;
|
||||
vector<int> values(10);
|
||||
generate(values.begin(), values.end(), ones());
|
||||
|
||||
vector<int> generated;
|
||||
copy(
|
||||
boost::make_function_input_iterator(ones_generator, 0),
|
||||
boost::make_function_input_iterator(ones_generator, 10),
|
||||
back_inserter(generated)
|
||||
);
|
||||
|
||||
assert(values.size() == generated.size());
|
||||
assert(equal(values.begin(), values.end(), generated.begin()));
|
||||
cout << "function iterator test with function objects successful." << endl;
|
||||
|
||||
// test the iterator with normal functions
|
||||
vector<int>().swap(generated);
|
||||
copy(
|
||||
boost::make_function_input_iterator(&ones_function, 0),
|
||||
boost::make_function_input_iterator(&ones_function, 10),
|
||||
back_inserter(generated)
|
||||
);
|
||||
|
||||
assert(values.size() == generated.size());
|
||||
assert(equal(values.begin(), values.end(), generated.begin()));
|
||||
cout << "function iterator test with pointer to function successful." << endl;
|
||||
|
||||
// test the iterator with a reference to a function
|
||||
vector<int>().swap(generated);
|
||||
copy(
|
||||
boost::make_function_input_iterator(ones_function, 0),
|
||||
boost::make_function_input_iterator(ones_function, 10),
|
||||
back_inserter(generated)
|
||||
);
|
||||
|
||||
assert(values.size() == generated.size());
|
||||
assert(equal(values.begin(), values.end(), generated.begin()));
|
||||
cout << "function iterator test with reference to function successful." << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,10 +7,6 @@
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/new_iterator_tests.hpp>
|
||||
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
|
||||
// This is a really, really limited test so far. All we're doing
|
||||
// right now is checking that the postfix++ proxy for single-pass
|
||||
// iterators works properly.
|
||||
@ -91,76 +87,26 @@ struct input_iter
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct wrapper
|
||||
{
|
||||
T m_x;
|
||||
explicit wrapper(typename boost::call_traits<T>::param_type x)
|
||||
: m_x(x)
|
||||
{ }
|
||||
template <class U>
|
||||
wrapper(const wrapper<U>& other,
|
||||
typename boost::enable_if< boost::is_convertible<U,T> >::type* = 0)
|
||||
: m_x(other.m_x)
|
||||
{ }
|
||||
};
|
||||
|
||||
struct iterator_with_proxy_reference
|
||||
: boost::iterator_facade<
|
||||
iterator_with_proxy_reference
|
||||
, wrapper<int>
|
||||
, boost::incrementable_traversal_tag
|
||||
, wrapper<int&>
|
||||
>
|
||||
{
|
||||
int& m_x;
|
||||
explicit iterator_with_proxy_reference(int& x)
|
||||
: m_x(x)
|
||||
{ }
|
||||
|
||||
void increment()
|
||||
{ }
|
||||
wrapper<int&> dereference() const
|
||||
{ return wrapper<int&>(m_x); }
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
void same_type(U const&)
|
||||
{ BOOST_MPL_ASSERT((boost::is_same<T,U>)); }
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int state = 0;
|
||||
boost::readable_iterator_test(counter_iterator<int const&>(&state), 0);
|
||||
state = 3;
|
||||
boost::readable_iterator_test(counter_iterator<proxy>(&state), 3);
|
||||
boost::writable_iterator_test(counter_iterator<proxy>(&state), 9, 7);
|
||||
BOOST_TEST(state == 8);
|
||||
}
|
||||
int state = 0;
|
||||
boost::readable_iterator_test(counter_iterator<int const&>(&state), 0);
|
||||
state = 3;
|
||||
boost::readable_iterator_test(counter_iterator<proxy>(&state), 3);
|
||||
boost::writable_iterator_test(counter_iterator<proxy>(&state), 9, 7);
|
||||
BOOST_TEST(state == 8);
|
||||
|
||||
{
|
||||
// test for a fix to http://tinyurl.com/zuohe
|
||||
// These two lines should be equivalent (and both compile)
|
||||
input_iter p;
|
||||
(*p).mutator();
|
||||
p->mutator();
|
||||
|
||||
same_type<input_iter::pointer>(p.operator->());
|
||||
}
|
||||
|
||||
{
|
||||
int x = 0;
|
||||
iterator_with_proxy_reference i(x);
|
||||
BOOST_TEST(x == 0);
|
||||
BOOST_TEST(i.m_x == 0);
|
||||
++(*i).m_x;
|
||||
BOOST_TEST(x == 1);
|
||||
BOOST_TEST(i.m_x == 1);
|
||||
++i->m_x;
|
||||
BOOST_TEST(x == 2);
|
||||
BOOST_TEST(i.m_x == 2);
|
||||
}
|
||||
// test for a fix to http://tinyurl.com/zuohe
|
||||
// These two lines should be equivalent (and both compile)
|
||||
input_iter p;
|
||||
(*p).mutator();
|
||||
p->mutator();
|
||||
|
||||
same_type<input_iter::pointer>(p.operator->());
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
// Moved test of transform iterator into its own file. It to
|
||||
// to be in iterator_adaptor_test.cpp.
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <algorithm>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
@ -107,17 +106,11 @@ struct polymorphic_mult_functor
|
||||
{
|
||||
//Implement result_of protocol
|
||||
template <class FArgs> struct result;
|
||||
template <class F, class T> struct result<const F(T )> {typedef T type;};
|
||||
template <class F, class T> struct result<const F(T& )> {typedef T type;};
|
||||
template <class F, class T> struct result<const F(const T&)> {typedef T type;};
|
||||
template <class F, class T> struct result<F(T )> {typedef void type;};
|
||||
template <class F, class T> struct result<F(T& )> {typedef void type;};
|
||||
template <class F, class T> struct result<F(const T&)> {typedef void type;};
|
||||
template <class F, class T> struct result<F(T)> {typedef T type;};
|
||||
|
||||
template <class T>
|
||||
T operator()(const T& _arg) const {return _arg*2;}
|
||||
template <class T>
|
||||
void operator()(const T& _arg) { BOOST_ASSERT(0); }
|
||||
typename result<polymorphic_mult_functor(T)>::type
|
||||
operator()(const T& _arg) const {return _arg*2;}
|
||||
};
|
||||
|
||||
int
|
||||
|
Reference in New Issue
Block a user