Boost C++ Libraries: Ticket #5929: empty(), data(), size() https://svn.boost.org/trac10/ticket/5929 <p> While not being operators, those functions can be defined in terms of others. empty(): end() == begin() data(): empty() ? NULL : &amp;*begin() size(): end() - begin() </p> <p> Could those be added to the operators lib? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5929 Trac 1.4.3 Daniel Frey Fri, 23 Sep 2011 11:16:15 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5929#comment:1 https://svn.boost.org/trac10/ticket/5929#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">wontfix</span> </li> </ul> <p> There are several issues here: </p> <p> a) Domain - Currlenty, operators are arithmetic operators or iterator support. In your case, they are now container support (and not even real operators). I would like to restrict the operators library to what it is, I even think about splitting it into two libraries from time to time. Adding more operators (or operator-like functions) does not seem like a good idea. </p> <p> b) Naming - How would you call the new base classes? emptyable? data-able? I don't see any obvious names for them. </p> <p> c) Efficiency - If end() is O(n), so are empty(), data() and size(), although O(1) might be possible. Are we sure users get that or that it is unlikely enough to not be a problem? </p> <p> d) Convenience - The (IMHO) real power of the operators library is, that there are groups of operators and <strong>that</strong> saves you from typing the same code over and over again. Plus that we ensure exploiting optimizations (RVO/NRVO) that some people might otherwise miss. For your case, there doesn't seem to be much gained by replacing the proposed functions by a base class each. </p> <p> I am thus closing this ticket as "wontfix", if you disagree, feel free to reopen it or discuss it on the mailing list. </p> Ticket anonymous Fri, 23 Sep 2011 11:36:20 GMT <link>https://svn.boost.org/trac10/ticket/5929#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5929#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5929#comment:1" title="Comment 1">daniel_frey</a>: </p> <blockquote class="citation"> <p> a) Domain b) Naming - How would you call the new base classes? emptyable? data-able? I don't see any obvious names for them. </p> </blockquote> <p> If the functionality provided is good, those issues should not be deal breakers. </p> <p> BTW, iterator support doesn't sound like arithmetic either. </p> <blockquote class="citation"> <p> c) Efficiency - If end() is O(n), so are empty(), data() and size(), although O(1) might be possible. </p> </blockquote> <p> Is O(n) allowed for end()? </p> <blockquote class="citation"> <p> Are we sure users get that or that it is unlikely enough to not be a problem? </p> </blockquote> <p> I think it's not a problem. </p> <blockquote class="citation"> <p> d) Convenience - The (IMHO) real power of the operators library is, that there are groups of operators and <strong>that</strong> saves you from typing the same code over and over again. Plus that we ensure exploiting optimizations (RVO/NRVO) that some people might otherwise miss. For your case, there doesn't seem to be much gained by replacing the proposed functions by a base class each. </p> </blockquote> <p> You already have indexable. Doesn't indexable imply random access? If not, don't you have the same O issue as end() you raised above? I think indexable implies empty(), data() and size() being suitable functions. </p> </description> <category>Ticket</category> </item> <item> <author>olafvdspek@…</author> <pubDate>Fri, 23 Sep 2011 15:28:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5929#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5929#comment:3</guid> <description> <p> There's also front(), back(), pop_front() and pop_back(). And maybe at(). </p> <p> BTW, I can't reopen the ticket as I don't have an account. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel Frey</dc:creator> <pubDate>Sun, 25 Sep 2011 14:30:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5929#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5929#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5929#comment:2" title="Comment 2">anonymous</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5929#comment:1" title="Comment 1">daniel_frey</a>: </p> <blockquote class="citation"> <p> a) Domain </p> </blockquote> <p> BTW, iterator support doesn't sound like arithmetic either. </p> </blockquote> <p> Well, yes, that's why I said that I think about splitting the Operators Library. Since I worked on the arithmetics part (including rvalue-support), please allow me to finished it and post a proposal to the list. The remaining part (iterator support) could than be turned into its own library, not concentrating on operators, but on supporting iterators/containers in general, where adding more non-operator methods makes more sense than for the Operators Library. Maybe you want to become the main developer/maintainer of that part? </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <olafvdspek@…></author> <pubDate>Mon, 26 Sep 2011 11:14:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5929#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5929#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5929#comment:4" title="Comment 4">daniel_frey</a>: </p> <blockquote class="citation"> <p> Maybe you want to become the main developer/maintainer of that part? </p> </blockquote> <p> Sure, that'd be great. </p> </description> <category>Ticket</category> </item> </channel> </rss>