Boost C++ Libraries: Ticket #2222: Make images & views model Collection concept. https://svn.boost.org/trac10/ticket/2222 <p> It would be convenient if GIL views modeled <a href="http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html">ReversibleCollection</a> concept. In fact they <em>almost</em> do already. </p> <p> Without modeling this concept, it is hard to use an image view with boost::range algorithms. </p> <p> Suggested patch: </p> <div class="wiki-code"> <div class="diff"> <ul class="entries"> <li class="entry"> <h2> <a>image_view.hpp</a> </h2> <table class="trac-diff inline" cellspacing="0"> <colgroup> <col class="lineno"/><col class="lineno"/><col class="content"/> </colgroup> <thead> <tr> <th title="File image_view.hpp (revision 48190)"> </th> <th title="File image_view.hpp (working copy)"> </th> <td> <em></em> &nbsp; </td> </tr> </thead> <tbody class="unmod"> <tr> <th>82</th><th>82</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; typedef typename Loc::template axis&lt;D&gt;::iterator iterator;&nbsp; &nbsp; &nbsp; &nbsp;// 1D iterator type along each dimension</span></td> </tr> <tr> <th>83</th><th>83</th><td class="l"><span>&nbsp; &nbsp; };</span></td> </tr> <tr> <th>84</th><th>84</th><td class="l"><span>&nbsp; &nbsp; typedef iterator_from_2d&lt;Loc&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iterator;&nbsp; &nbsp; &nbsp; &nbsp;// 1D iterator type for each pixel left-to-right inside top-to-bottom</span></td> </tr> </tbody> <tbody class="add"> <tr class="first"> <th>&nbsp;</th><th>85</th><td class="r"><ins>&nbsp; &nbsp; typedef typename const_t::iterator&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const_iterator;</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>86</th><td class="r"><ins>&nbsp; &nbsp; typedef typename const_t::reference&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const_reference;</ins></td> </tr> <tr class="last"> <th>&nbsp;</th><th>87</th><td class="r"><ins>&nbsp; &nbsp; typedef typename std::iterator_traits&lt;iterator&gt;::pointer pointer;</ins></td> </tr> </tbody> <tbody class="unmod"> <tr> <th>85</th><th>88</th><td class="l"><span>&nbsp; &nbsp; typedef std::reverse_iterator&lt;iterator&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; reverse_iterator;</span></td> </tr> <tr> <th>86</th><th>89</th><td class="l"><span>&nbsp; &nbsp; typedef std::size_t&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; size_type;</span></td> </tr> <tr> <th>87</th><th>90</th><td class="l"><span></span></td> </tr> </tbody> <tbody class="skipped"> <tr> <th><a href="#L111">&hellip;</a></th> <th><a href="#L114">&hellip;</a></th> <td> <em></em> &nbsp; </td> </tr> </tbody> <tbody class="unmod"> <tr> <th>111</th><th>114</th><td class="l"><span></span></td> </tr> <tr> <th>112</th><th>115</th><td class="l"><span>&nbsp; &nbsp; template &lt;typename L2&gt; friend void swap(image_view&lt;L2&gt;&amp; x, image_view&lt;L2&gt;&amp; y);</span></td> </tr> <tr> <th>113</th><th>116</th><td class="l"><span></span></td> </tr> </tbody> <tbody class="add"> <tr class="first"> <th>&nbsp;</th><th>117</th><td class="r"><ins>&nbsp; &nbsp; ///\brief Exchanges the elements of the current view with those of \a other</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>118</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; &nbsp;in constant time.</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>119</th><td class="r"><ins>&nbsp; &nbsp; ///</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>120</th><td class="r"><ins>&nbsp; &nbsp; ///\note Required by concept</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>121</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>122</th><td class="r"><ins>&nbsp; &nbsp; void swap(image_view&lt;Loc&gt;&amp; other)</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>123</th><td class="r"><ins>&nbsp; &nbsp; {</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>124</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; swap(*this, other);</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>125</th><td class="r"><ins>&nbsp; &nbsp; }</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>126</th><td class="r"><ins></ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>127</th><td class="r"><ins></ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>128</th><td class="r"><ins></ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>129</th><td class="r"><ins>&nbsp; &nbsp; ///\brief Returns true if the view has no elements, false otherwise.</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>130</th><td class="r"><ins>&nbsp; &nbsp; ///</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>131</th><td class="r"><ins>&nbsp; &nbsp; ///\note Required by concept</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>132</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>133</th><td class="r"><ins>&nbsp; &nbsp; bool empty() const</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>134</th><td class="r"><ins>&nbsp; &nbsp; {</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>135</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; return width() &gt; 0 &amp;&amp; height() &gt; 0;</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>136</th><td class="r"><ins>&nbsp; &nbsp; }</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>137</th><td class="r"><ins></ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>138</th><td class="r"><ins>&nbsp; &nbsp; ///\brief Returns a reference to the first element in raster order.</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>139</th><td class="r"><ins>&nbsp; &nbsp; ///</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>140</th><td class="r"><ins>&nbsp; &nbsp; ///\note Required by concept</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>141</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>142</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; since views model ForwardCollection</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>143</th><td class="r"><ins>&nbsp; &nbsp; reference front() const</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>144</th><td class="r"><ins>&nbsp; &nbsp; {</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>145</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; return *begin();</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>146</th><td class="r"><ins>&nbsp; &nbsp; }</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>147</th><td class="r"><ins></ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>148</th><td class="r"><ins>&nbsp; &nbsp; ///\brief Returns a reference to the last element in raster order.</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>149</th><td class="r"><ins>&nbsp; &nbsp; ///</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>150</th><td class="r"><ins>&nbsp; &nbsp; ///\note Required by concept</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>151</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>152</th><td class="r"><ins>&nbsp; &nbsp; ///&nbsp; &nbsp; &nbsp; since views model ReversibleCollection</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>153</th><td class="r"><ins>&nbsp; &nbsp; reference back() const</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>154</th><td class="r"><ins>&nbsp; &nbsp; {</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>155</th><td class="r"><ins>&nbsp; &nbsp; &nbsp; &nbsp; return *rbegin();</ins></td> </tr> <tr class=""> <th>&nbsp;</th><th>156</th><td class="r"><ins>&nbsp; &nbsp; }</ins></td> </tr> <tr class="last"> <th>&nbsp;</th><th>157</th><td class="r"><ins></ins></td> </tr> </tbody> <tbody class="unmod"> <tr> <th>114</th><th>158</th><td class="l"><span>&nbsp; &nbsp; const point_t&amp;&nbsp; &nbsp;dimensions()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const { return _dimensions; }</span></td> </tr> <tr> <th>115</th><th>159</th><td class="l"><span>&nbsp; &nbsp; const locator&amp;&nbsp; &nbsp;pixels()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const { return _pixels; }</span></td> </tr> <tr> <th>116</th><th>160</th><td class="l"><span>&nbsp; &nbsp; x_coord_t&nbsp; &nbsp; &nbsp; &nbsp; width()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const { return dimensions().x; }</span></td> </tr> </tbody> </table> </li> </ul> </div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2222 Trac 1.4.3 John Maddock Tue, 19 Aug 2008 10:41:01 GMT component, milestone changed; owner set https://svn.boost.org/trac10/ticket/2222#comment:1 https://svn.boost.org/trac10/ticket/2222#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Hailin Jin</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">GIL</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.36.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket mloskot <mateusz@…> Sat, 03 Oct 2009 21:38:34 GMT cc set https://svn.boost.org/trac10/ticket/2222#comment:2 https://svn.boost.org/trac10/ticket/2222#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">mateusz@…</span> added </li> </ul> Ticket Stefan Seefeld Sat, 01 Jul 2017 21:09:39 GMT owner changed https://svn.boost.org/trac10/ticket/2222#comment:3 https://svn.boost.org/trac10/ticket/2222#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Hailin Jin</span> to <span class="trac-author">Stefan Seefeld</span> </li> </ul> Ticket Mateusz Loskot Mon, 25 Jun 2018 13:20:30 GMT cc changed https://svn.boost.org/trac10/ticket/2222#comment:4 https://svn.boost.org/trac10/ticket/2222#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">Mateusz Loskot</span> added </li> </ul> Ticket Mateusz Loskot Wed, 29 Aug 2018 14:30:15 GMT <link>https://svn.boost.org/trac10/ticket/2222#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2222#comment:5</guid> <description> <p> I believe, this condition </p> <pre class="wiki">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() &gt; 0 &amp;&amp; height() &gt; 0; 136 } </pre><p> should read </p> <pre class="wiki">return !(width() &gt; 0 &amp;&amp; height() &gt; 0); </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Mateusz Loskot</dc:creator> <pubDate>Wed, 29 Aug 2018 20:14:37 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2222#comment:6 https://svn.boost.org/trac10/ticket/2222#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> </ul> <p> Moved to <a class="ext-link" href="https://github.com/boostorg/gil/pull/133"><span class="icon">​</span>https://github.com/boostorg/gil/pull/133</a> </p> <p> Submited as PR against the current develop branch, with additions. </p> <p> Thanks for the suggestion and patch! </p> Ticket Mateusz Loskot Thu, 30 Aug 2018 14:02:54 GMT <link>https://svn.boost.org/trac10/ticket/2222#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2222#comment:7</guid> <description> <p> The suggestion has been merged via ​<a class="ext-link" href="https://github.com/boostorg/gil/pull/133"><span class="icon">​</span>https://github.com/boostorg/gil/pull/133</a> and should be released with Boost 1.69 </p> </description> <category>Ticket</category> </item> </channel> </rss>