Ticket #1947: boost-changes.diff
File boost-changes.diff, 10.2 KB (added by , 12 years ago) |
---|
-
boost/iterator/iterator_facade.hpp
352 352 : m_iter(iter) 353 353 {} 354 354 355 operator reference() const355 operator value_type() const 356 356 { 357 357 return *m_iter; 358 358 } -
boost/iterator/iterator_archetypes.hpp
84 84 assign_proxy& operator=(T) { return *this; } 85 85 }; 86 86 87 template <class T >87 template <class T, int id=0> 88 88 struct read_proxy 89 89 { 90 90 operator T() { return static_object<T>::get(); } 91 91 }; 92 92 93 template <class T >93 template <class T, int id=0> 94 94 struct read_write_proxy 95 : read_proxy<T> // Use to inherit from assign_proxy, but that doesn't work. -JGS95 : read_proxy<T,id> // Use to inherit from assign_proxy, but that doesn't work. -JGS 96 96 { 97 97 read_write_proxy& operator=(T) { return *this; } 98 98 }; 99 99 100 template <class T >100 template <class T, int id=0> 101 101 struct arrow_proxy 102 102 { 103 103 T const* operator->() const { return 0; } … … 108 108 template <class ValueType> 109 109 struct readable_operator_brackets 110 110 { 111 read_proxy<ValueType > operator[](std::ptrdiff_t n) const { return read_proxy<ValueType>(); }111 read_proxy<ValueType,1> operator[](std::ptrdiff_t n) const { return read_proxy<ValueType,1>(); } 112 112 }; 113 113 114 114 template <class ValueType> 115 115 struct writable_operator_brackets 116 116 { 117 read_write_proxy<ValueType > operator[](std::ptrdiff_t n) const { return read_write_proxy<ValueType>(); }117 read_write_proxy<ValueType,1> operator[](std::ptrdiff_t n) const { return read_write_proxy<ValueType,1>(); } 118 118 }; 119 119 120 120 template <class Value, class AccessCategory, class TraversalCategory> … … 307 307 template <class Value> struct archetype; 308 308 }; 309 309 310 template <class Value, class AccessCategory>311 struct iterator_access_archetype312 : mpl::aux::msvc_eti_base<313 typename iterator_access_archetype_impl<314 AccessCategory315 >::template archetype<Value>316 >::type317 {318 };319 320 310 template <> 321 311 struct iterator_access_archetype_impl< 322 312 iterator_archetypes::readable_iterator_t … … 326 316 struct archetype 327 317 { 328 318 typedef typename remove_cv<Value>::type value_type; 329 typedef Valuereference;330 typedef Value*pointer;319 typedef detail::read_proxy<Value> reference; 320 typedef detail::arrow_proxy<Value> pointer; 331 321 332 value_type operator*() const { return static_object<value_type>::get(); } 333 334 detail::arrow_proxy<Value> operator->() const { return detail::arrow_proxy<Value>(); } 322 reference operator*() const { return reference(); } 323 pointer operator->() const { return pointer(); } 335 324 }; 336 325 }; 337 326 … … 347 336 BOOST_STATIC_ASSERT(!is_const<Value>::value); 348 337 # endif 349 338 typedef void value_type; 350 typedef voidreference;339 typedef detail::assign_proxy<Value> reference; 351 340 typedef void pointer; 352 341 353 detail::assign_proxy<Value> operator*() const { return detail::assign_proxy<Value>(); }342 reference operator*() const { return reference(); } 354 343 }; 355 344 }; 356 345 346 template <class Value, class AccessCategory> 347 struct iterator_access_archetype 348 : 349 # ifdef BOOST_MSVC 350 mpl::aux::msvc_eti_base< 351 # endif 352 iterator_access_archetype_impl< 353 AccessCategory 354 >::template archetype<Value> 355 # ifdef BOOST_MSVC 356 >::type 357 # endif 358 { 359 }; 360 357 361 template <> 358 362 struct iterator_access_archetype_impl< 359 363 iterator_archetypes::readable_writable_iterator_t … … 367 371 { 368 372 typedef detail::read_write_proxy<Value> reference; 369 373 370 detail::read_write_proxy<Value> operator*() const { return detail::read_write_proxy<Value>(); }374 reference operator*() const { return reference(); } 371 375 }; 372 376 }; 373 377 … … 511 515 512 516 } // namespace boost 513 517 514 518 namespace std 519 { 520 template <class Value, class AccessCategory, class TraversalCategory> 521 struct iterator_traits< 522 boost::iterator_archetype<Value, AccessCategory, TraversalCategory> 523 > 524 : boost::detail::iterator_archetype_base< 525 Value,AccessCategory,TraversalCategory 526 > 527 {}; 528 } 515 529 #endif // BOOST_ITERATOR_ARCHETYPES_HPP -
boost/iterator/iterator_concepts.hpp
8 8 9 9 #include <boost/concept_check.hpp> 10 10 #include <boost/iterator/iterator_categories.hpp> 11 #include <boost/iterator/is_readable_iterator.hpp> 11 12 12 13 // Use boost::detail::iterator_traits to work around some MSVC/Dinkumware problems. 13 14 #include <boost/detail/iterator.hpp> … … 191 192 i -= n; 192 193 i = i - n; 193 194 n = i - j; 195 check_brackets(boost::is_readable_iterator<Iterator>()); 194 196 } 197 198 void check_brackets(boost::mpl::false_) {} 199 void check_brackets(boost::mpl::true_) 200 { 201 typename ReadableIterator<Iterator>::value_type x = i[n]; 202 boost::ignore_unused_variable_warning(x); 203 } 195 204 196 205 private: 197 206 typename BidirectionalTraversal<Iterator>::difference_type n; -
boost/concept_archetype.hpp
604 604 self operator++(int) { return *this; } 605 605 self& operator--() { return *this; } 606 606 self operator--(int) { return *this; } 607 referenceoperator[](difference_type) const608 { return static_object<T>::get(); }607 convertible_to_archetype<T> operator[](difference_type) const 608 { return detail::dummy_constructor(); } 609 609 self& operator+=(difference_type) { return *this; } 610 610 self& operator-=(difference_type) { return *this; } 611 611 difference_type operator-(const self&) const … … 644 644 self operator++(int) { return *this; } 645 645 self& operator--() { return *this; } 646 646 self operator--(int) { return *this; } 647 referenceoperator[](difference_type) const648 { return static_object<T>::get(); }647 convertible_to_archetype<T> operator[](difference_type) const 648 { return detail::dummy_constructor(); } 649 649 self& operator+=(difference_type) { return *this; } 650 650 self& operator-=(difference_type) { return *this; } 651 651 difference_type operator-(const self&) const -
boost/concept_check.hpp
573 573 i -= n; // require assignment subtraction operator 574 574 i = i - n; // require subtraction with difference type 575 575 n = i - j; // require difference operator 576 (void)i[n]; // require element access operator 576 577 // require element access operator 578 typename boost::detail::iterator_traits<TT>::value_type v = i[n]; 579 ignore_unused_variable_warning(v); 577 580 } 578 581 579 582 private: -
libs/iterator/test/iterator_adaptor_cc.cpp
5 5 6 6 #include <boost/iterator/reverse_iterator.hpp> 7 7 #include <boost/iterator/iterator_concepts.hpp> 8 #include <boost/iterator/iterator_archetypes.hpp> 8 9 #include <boost/concept_check.hpp> 10 #include <boost/type_traits/is_same.hpp> 9 11 #include <boost/cstdlib.hpp> 10 12 #include <list> 11 13 14 template <class archetype> 15 struct adaptor_passthru 16 : boost::iterator_adaptor<adaptor_passthru<archetype>, archetype> 17 { 18 }; 19 20 struct dummy_value_type {}; 21 22 typedef boost::iterator_archetype< 23 dummy_value_type, boost::iterator_archetypes::readable_iterator_t, 24 boost::random_access_traversal_tag> 25 random_traversal_archetype; 26 27 template <class T, class U> 28 void assert_not_same(T const& x, U const& y) 29 { 30 BOOST_MPL_ASSERT_NOT((boost::is_same<T,U>)); 31 } 32 12 33 int main() 13 34 { 14 35 { … … 20 41 boost::function_requires< boost_concepts::RandomAccessTraversalConcept<rev_iter> >(); 21 42 boost::function_requires< boost::RandomAccessIteratorConcept<rev_iter> >(); 22 43 boost::function_requires< boost_concepts::InteroperableIteratorConcept<rev_iter, c_rev_iter> >(); 44 45 // Make sure we're testing what we mean to, below. Given a proxy 46 // iterator, its reference type and its operator brackets result 47 // may be unrelated. 48 random_traversal_archetype it; 49 assert_not_same(*it, it[0]); 50 51 // In particular, tests that passing our 52 // random_traversal_archetype through iterator_adaptor preserves 53 // the ability to convert i[n] into the value type. 54 BOOST_CONCEPT_ASSERT(( 55 boost_concepts::RandomAccessTraversal< 56 adaptor_passthru< 57 random_traversal_archetype 58 > 59 > 60 )); 23 61 } 24 62 25 63 // Many compilers' builtin container iterators don't interoperate well, though -
libs/iterator/test/concept_tests.cpp
16 16 : public boost::iterator< new_random_access, int > 17 17 { 18 18 int& operator*() const { return *m_x; } 19 int& operator[](difference_type n) const { return *(m_x+n); } 19 20 new_iterator& operator++() { return *this; } 20 21 new_iterator operator++(int) { return *this; } 21 22 new_iterator& operator--() { return *this; } … … 36 37 : public boost::iterator<std::random_access_iterator_tag, int> 37 38 { 38 39 int& operator*() const { return *m_x; } 40 int& operator[](difference_type n) const { return *(m_x+n); } 39 41 old_iterator& operator++() { return *this; } 40 42 old_iterator operator++(int) { return *this; } 41 43 old_iterator& operator--() { return *this; }