Boost C++ Libraries: Ticket #5930: data() for iterator_range https://svn.boost.org/trac10/ticket/5930 <p> Could you add the data() member to iterator_range? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5930 Trac 1.4.3 Steven Watanabe Fri, 23 Sep 2011 17:35:22 GMT <link>https://svn.boost.org/trac10/ticket/5930#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:1</guid> <description> <p> What exactly is iterator_range::data supposed to return? </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Fri, 23 Sep 2011 19:43:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:2</guid> <description> <p> return empty() ? NULL : &amp;front(); </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Fri, 23 Sep 2011 20:50:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:3</guid> <description> <p> This is rather dangerous. It only works if the iterator points to contiguous storage. </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Sun, 25 Sep 2011 16:59:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:4</guid> <description> <p> Right, it should only be provided in that case. </p> </description> <category>Ticket</category> </item> <item> <author>rhys.ulerich@…</author> <pubDate>Mon, 07 Nov 2011 15:39:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:5</guid> <description> <p> How can a member method be provided only under certain runtime conditions? It seems the existing class methods do what one needs and that data() could be written as a free function. </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Mon, 07 Nov 2011 15:43:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5930#comment:5" title="Comment 5">rhys.ulerich@…</a>: </p> <blockquote class="citation"> <p> How can a member method be provided only under certain runtime conditions? </p> </blockquote> <p> It's not a runtime condition. </p> <blockquote class="citation"> <p> It seems the existing class methods do what one needs and that data() could be written as a free function. </p> </blockquote> <p> A free function that'd work for all containers / ranges that support random access would be fine too. </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Mon, 07 Nov 2011 15:44:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:7</guid> <description> <p> Except that C++11 has data() for array, string, vector and probably others, so there's probably a good reason against a free function. </p> </description> <category>Ticket</category> </item> <item> <author>rhys.ulerich@…</author> <pubDate>Mon, 07 Nov 2011 15:48:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:8</guid> <description> <p> Referring to... </p> <blockquote class="citation"> <blockquote class="citation"> <blockquote class="citation"> <p> return empty() ? NULL : &amp;front(); </p> </blockquote> <p> This is rather dangerous. It only works if the iterator points to contiguous storage. </p> </blockquote> <p> Right, it should only be provided in that case. </p> </blockquote> <p> I asked... </p> <blockquote class="citation"> <blockquote class="citation"> <p> How can a member method be provided only under certain runtime conditions? </p> </blockquote> <p> It's not a runtime condition. </p> </blockquote> <p> An iterator_range knowing that it represents a contiguous region of memory seems like a runtime condition to me. What am I missing? </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Mon, 07 Nov 2011 15:50:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5930#comment:8" title="Comment 8">rhys.ulerich@…</a>: </p> <blockquote class="citation"> <p> An iterator_range knowing that it represents a contiguous region of memory seems like a runtime condition to me. What am I missing? </p> </blockquote> <p> It's a compile time condition. True for pointers, arrays, array, vector and string. False for a lot of other things. </p> </description> <category>Ticket</category> </item> <item> <author>rhys.ulerich@…</author> <pubDate>Mon, 07 Nov 2011 15:53:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:10</guid> <description> <blockquote class="citation"> <blockquote class="citation"> <p> An iterator_range knowing that it represents a contiguous region of memory seems like a runtime condition to me. What am I missing? </p> </blockquote> <p> It's a compile time condition. True for pointers, arrays, array, vector and string. False for a lot of other things. </p> </blockquote> <p> Ahh.. Good point. My mistake. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 10 Sep 2013 20:31:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:11</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5930#comment:4" title="Comment 4">Olaf van der Spek &lt;olafvdspek@…&gt;</a>: </p> <blockquote class="citation"> <p> Right, it should only be provided in that case. </p> </blockquote> <p> How the user could know that the function is provided only under some special circumstances? Could you show a real use case? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 10 Sep 2013 22:41:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5930#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:12</guid> <description> <p> I'm sure Google can give you enough real use cases for data(). It's a standard function. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Fri, 21 Feb 2014 20:23:18 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5930#comment:13 https://svn.boost.org/trac10/ticket/5930#comment:13 <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">wontfix</span> </li> </ul> <p> While a member data() function exists for some containers in the standard library it does not make sense to conditionally add this to iterator_range. </p> <p> If you know enough about the iterator that this function can work then it is trivial to implement a non-member function that is more broadly applicable. </p> Ticket anonymous Sat, 22 Feb 2014 10:35:59 GMT <link>https://svn.boost.org/trac10/ticket/5930#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5930#comment:14</guid> <description> <p> But ISO C++ has data() as a member function, not as a non-member function. </p> </description> <category>Ticket</category> </item> </channel> </rss>