Ticket #5697: iterator_facade.hpp.patch
File iterator_facade.hpp.patch, 4.4 KB (added by , 11 years ago) |
---|
-
D:/boost_1_47_0/boost/iterator/iterator_facade.
old new 14 14 #include <boost/iterator/detail/facade_iterator_category.hpp> 15 15 #include <boost/iterator/detail/enable_if.hpp> 16 16 17 #include <boost/implicit_cast.hpp>18 17 #include <boost/static_assert.hpp> 18 #include <boost/utility/addressof.hpp> 19 19 20 20 #include <boost/type_traits/is_same.hpp> 21 21 #include <boost/type_traits/add_const.hpp> … … 294 294 295 295 // operator->() needs special support for input iterators to strictly meet the 296 296 // standard's requirements. If *i is not a reference type, we must still 297 // produce a lvalue to which a pointer can be formed. We do that by298 // returning a n instantiation of this special proxy class template.299 template <class T>300 struct operator_arrow_ proxy297 // produce a lvalue to which a pointer can be formed. We do that by 298 // returning a proxy object containing an instance of the reference object. 299 template <class Reference, class Pointer> 300 struct operator_arrow_dispatch // proxy references 301 301 { 302 operator_arrow_proxy(T const* px) : m_value(*px) {} 303 T* operator->() const { return &m_value; } 304 // This function is needed for MWCW and BCC, which won't call operator-> 305 // again automatically per 13.3.1.2 para 8 306 operator T*() const { return &m_value; } 307 mutable T m_value; 302 struct proxy 303 { 304 explicit proxy(Reference const & x) : m_ref(x) {} 305 Reference* operator->() { return boost::addressof(m_ref); } 306 // This function is needed for MWCW and BCC, which won't call 307 // operator-> again automatically per 13.3.1.2 para 8 308 operator Reference*() { return boost::addressof(m_ref); } 309 Reference m_ref; 310 }; 311 typedef proxy result_type; 312 static result_type apply(Reference const & x) 313 { 314 return result_type(x); 315 } 308 316 }; 309 317 310 // A metafunction that gets the result type for operator->. Also 311 // has a static function make() which builds the result from a 312 // Reference 313 template <class ValueType, class Reference, class Pointer> 314 struct operator_arrow_result 318 template <class T, class Pointer> 319 struct operator_arrow_dispatch<T&, Pointer> // "real" references 315 320 { 316 // CWPro8.3 won't accept "operator_arrow_result::type", and we 317 // need that type below, so metafunction forwarding would be a 318 // losing proposition here. 319 typedef typename mpl::if_< 320 is_reference<Reference> 321 , Pointer 322 , operator_arrow_proxy<ValueType> 323 >::type type; 324 325 static type make(Reference x) 321 typedef Pointer result_type; 322 static result_type apply(T& x) 326 323 { 327 return boost:: implicit_cast<type>(&x);324 return boost::addressof(x); 328 325 } 329 326 }; 330 327 331 328 # if BOOST_WORKAROUND(BOOST_MSVC, < 1300) 332 329 // Deal with ETI 333 330 template<> 334 struct operator_arrow_ result<int,int, int>331 struct operator_arrow_dispatch<int, int> 335 332 { 336 typedef int type;333 typedef int result_type; 337 334 }; 338 335 # endif 339 336 … … 618 615 Value, CategoryOrTraversal, Reference, Difference 619 616 > associated_types; 620 617 621 typedef boost::detail::operator_arrow_result< 622 typename associated_types::value_type 623 , Reference 618 typedef boost::detail::operator_arrow_dispatch< 619 Reference 624 620 , typename associated_types::pointer 625 > pointer_;621 > operator_arrow_dispatch_; 626 622 627 623 protected: 628 624 // For use by derived classes … … 634 630 typedef Reference reference; 635 631 typedef Difference difference_type; 636 632 637 typedef typename pointer_::type pointer;633 typedef typename operator_arrow_dispatch_::result_type pointer; 638 634 639 635 typedef typename associated_types::iterator_category iterator_category; 640 636 … … 645 641 646 642 pointer operator->() const 647 643 { 648 return pointer_::make(*this->derived());644 return operator_arrow_dispatch_::apply(*this->derived()); 649 645 } 650 646 651 647 typename boost::detail::operator_brackets_result<Derived,Value,reference>::type