Boost C++ Libraries: Ticket #2223: Make images & views model Collection concept. https://svn.boost.org/trac10/ticket/2223 <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/2223 Trac 1.4.3 Steven Watanabe Sun, 06 Jun 2010 22:45:52 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2223#comment:1 https://svn.boost.org/trac10/ticket/2223#comment:1 <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> Duplicates <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2222" title="#2222: Feature Requests: Make images &amp; views model Collection concept. (closed: duplicate)">#2222</a>. </p> Ticket