#2222 closed Feature Requests (duplicate)
Make images & views model Collection concept.
Reported by: | Owned by: | Stefan Seefeld | |
---|---|---|---|
Milestone: | To Be Determined | Component: | gil USE GITHUB |
Version: | Boost 1.36.0 | Severity: | Problem |
Keywords: | Cc: | mateusz@…, Mateusz Loskot |
Description
It would be convenient if GIL views modeled 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:
-
image_view.hpp
82 82 typedef typename Loc::template axis<D>::iterator iterator; // 1D iterator type along each dimension 83 83 }; 84 84 typedef iterator_from_2d<Loc> iterator; // 1D iterator type for each pixel left-to-right inside top-to-bottom 85 typedef typename const_t::iterator const_iterator; 86 typedef typename const_t::reference const_reference; 87 typedef typename std::iterator_traits<iterator>::pointer pointer; 85 88 typedef std::reverse_iterator<iterator> reverse_iterator; 86 89 typedef std::size_t size_type; 87 90 … … 111 114 112 115 template <typename L2> friend void swap(image_view<L2>& x, image_view<L2>& y); 113 116 117 ///\brief Exchanges the elements of the current view with those of \a other 118 /// in constant time. 119 /// 120 ///\note Required by concept 121 /// http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html 122 void swap(image_view<Loc>& other) 123 { 124 swap(*this, other); 125 } 126 127 128 129 ///\brief Returns true if the view has no elements, false otherwise. 130 /// 131 ///\note Required by concept 132 /// http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html 133 bool empty() const 134 { 135 return width() > 0 && height() > 0; 136 } 137 138 ///\brief Returns a reference to the first element in raster order. 139 /// 140 ///\note Required by concept 141 /// http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html 142 /// since views model ForwardCollection 143 reference front() const 144 { 145 return *begin(); 146 } 147 148 ///\brief Returns a reference to the last element in raster order. 149 /// 150 ///\note Required by concept 151 /// http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html 152 /// since views model ReversibleCollection 153 reference back() const 154 { 155 return *rbegin(); 156 } 157 114 158 const point_t& dimensions() const { return _dimensions; } 115 159 const locator& pixels() const { return _pixels; } 116 160 x_coord_t width() const { return dimensions().x; }
Change History (7)
comment:1 by , 14 years ago
Component: | None → GIL |
---|---|
Milestone: | Boost 1.36.0 → To Be Determined |
Owner: | set to |
comment:2 by , 13 years ago
Cc: | added |
---|
comment:3 by , 5 years ago
Owner: | changed from | to
---|
comment:4 by , 4 years ago
Cc: | added |
---|
comment:5 by , 4 years ago
comment:6 by , 4 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Moved to https://github.com/boostorg/gil/pull/133
Submited as PR against the current develop branch, with additions.
Thanks for the suggestion and patch!
comment:7 by , 4 years ago
The suggestion has been merged via https://github.com/boostorg/gil/pull/133 and should be released with Boost 1.69
Note:
See TracTickets
for help on using tickets.
I believe, this condition
should read