mirror of
https://github.com/boostorg/iterator.git
synced 2025-05-11 13:33:56 +00:00
Made sure that iterator_facade's nested `::pointer
` type is always
the same as what's returned from operator->. For input iterators, that wasn't always the case (see operator_arrow_proxy). Fixes #1019. [SVN r57989]
This commit is contained in:
parent
d11c7a3ec4
commit
4c60e26bf8
@ -105,6 +105,7 @@ namespace boost
|
||||
|
||||
typedef typename remove_const<ValueParam>::type value_type;
|
||||
|
||||
// Not the real associated pointer type
|
||||
typedef typename mpl::eval_if<
|
||||
boost::detail::iterator_writability_disabled<ValueParam,Reference>
|
||||
, add_pointer<const value_type>
|
||||
@ -617,6 +618,12 @@ namespace boost
|
||||
Value, CategoryOrTraversal, Reference, Difference
|
||||
> associated_types;
|
||||
|
||||
typedef boost::detail::operator_arrow_result<
|
||||
typename associated_types::value_type
|
||||
, Reference
|
||||
, typename associated_types::pointer
|
||||
> pointer_;
|
||||
|
||||
protected:
|
||||
// For use by derived classes
|
||||
typedef iterator_facade<Derived,Value,CategoryOrTraversal,Reference,Difference> iterator_facade_;
|
||||
@ -626,7 +633,9 @@ namespace boost
|
||||
typedef typename associated_types::value_type value_type;
|
||||
typedef Reference reference;
|
||||
typedef Difference difference_type;
|
||||
typedef typename associated_types::pointer pointer;
|
||||
|
||||
typedef typename pointer_::type pointer;
|
||||
|
||||
typedef typename associated_types::iterator_category iterator_category;
|
||||
|
||||
reference operator*() const
|
||||
@ -634,18 +643,9 @@ namespace boost
|
||||
return iterator_core_access::dereference(this->derived());
|
||||
}
|
||||
|
||||
typename boost::detail::operator_arrow_result<
|
||||
value_type
|
||||
, reference
|
||||
, pointer
|
||||
>::type
|
||||
operator->() const
|
||||
pointer operator->() const
|
||||
{
|
||||
return boost::detail::operator_arrow_result<
|
||||
value_type
|
||||
, reference
|
||||
, pointer
|
||||
>::make(*this->derived());
|
||||
return pointer_::make(*this->derived());
|
||||
}
|
||||
|
||||
typename boost::detail::operator_brackets_result<Derived,Value,reference>::type
|
||||
|
6
test/iterator_facade.cpp
Executable file → Normal file
6
test/iterator_facade.cpp
Executable file → Normal file
@ -87,6 +87,10 @@ struct input_iter
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
void same_type(U const&)
|
||||
{ BOOST_MPL_ASSERT((boost::is_same<T,U>)); }
|
||||
|
||||
int main()
|
||||
{
|
||||
int state = 0;
|
||||
@ -101,6 +105,8 @@ int main()
|
||||
input_iter p;
|
||||
(*p).mutator();
|
||||
p->mutator();
|
||||
|
||||
same_type<input_iter::pointer>(p.operator->());
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user