id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 2223,Make images & views model Collection concept.,john.femiani@…,Hailin Jin,"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::iterator iterator; // 1D iterator type along each dimension }; typedef iterator_from_2d 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::pointer pointer; typedef std::reverse_iterator reverse_iterator; typedef std::size_t size_type; @@ -111,6 +114,47 @@ template friend void swap(image_view& x, image_view& 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& 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; } }}} ",Feature Requests,closed,Boost 1.36.0,gil USE GITHUB,Boost 1.36.0,Problem,duplicate,,