[Boost-bugs] [Boost C++ Libraries] #2222: Make images & views model Collection concept.

Subject: [Boost-bugs] [Boost C++ Libraries] #2222: Make images & views model Collection concept.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-08-19 08:14:07


#2222: Make images & views model Collection concept.
----------------------------------+-----------------------------------------
 Reporter: john.femiani_at_[hidden] | Type: Feature Requests
   Status: new | Milestone: Boost 1.36.0
Component: None | Version: Boost 1.36.0
 Severity: Problem | Keywords:
----------------------------------+-----------------------------------------
 It would be convenient if GIL views modeled
 [http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
 ReversibleCollection] concept.
 In fact they ''almost'' do already.

 Without modeling this concept, it is hard to use an image view with
 boost::range algorithms.



 Suggested patch:
 {{{
 #!patch
 Index: image_view.hpp
 ===================================================================
 --- image_view.hpp (revision 48190)
 +++ image_view.hpp (working copy)
 @@ -82,6 +82,9 @@
          typedef typename Loc::template axis<D>::iterator iterator;
 // 1D iterator type along each dimension
      };
      typedef iterator_from_2d<Loc> iterator; //
 1D iterator type for each pixel left-to-right inside top-to-bottom
 + typedef typename const_t::iterator const_iterator;
 + typedef typename const_t::reference const_reference;
 + typedef typename std::iterator_traits<iterator>::pointer pointer;
      typedef std::reverse_iterator<iterator> reverse_iterator;
      typedef std::size_t size_type;

 @@ -111,6 +114,47 @@

      template <typename L2> friend void swap(image_view<L2>& x,
 image_view<L2>& y);

 + ///\brief Exchanges the elements of the current view with those of \a
 other
 + /// in constant time.
 + ///
 + ///\note Required by concept
 + ///
 http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
 + void swap(image_view<Loc>& other)
 + {
 + swap(*this, other);
 + }
 +
 +
 +
 + ///\brief Returns true if the view has no elements, false otherwise.
 + ///
 + ///\note Required by concept
 + ///
 http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
 + bool empty() const
 + {
 + return width() > 0 && height() > 0;
 + }
 +
 + ///\brief Returns a reference to the first element in raster order.
 + ///
 + ///\note Required by concept
 + ///
 http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
 + /// since views model ForwardCollection
 + reference front() const
 + {
 + return *begin();
 + }
 +
 + ///\brief Returns a reference to the last element in raster order.
 + ///
 + ///\note Required by concept
 + ///
 http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
 + /// since views model ReversibleCollection
 + reference back() const
 + {
 + return *rbegin();
 + }
 +
      const point_t& dimensions() const { return _dimensions;
 }
      const locator& pixels() const { return _pixels; }
      x_coord_t width() const { return
 dimensions().x; }

 }}}

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2222>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC