Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT</strong>: <em>This is not really answering the question as pointed in the comments. I'll just leave the post here in the case it's useful anyhow...</em></p> <p>I think this is pretty much a matter of syntax unification towards a better usable interface. When providing such member functions without differentiating the name and letting only the overload resolution mechanism determine the correct version you prevent (or at least try to) the programmer from making <code>const</code> related worries.</p> <p>I know this might seem contradictory, in particular given your example. But if you think on most of the use cases it makes sense. Take an STL algorithm like <code>std::equal</code>. No matter whether your container is constant or not, you can always code something like <code>bool e = std::equal(c.begin(), c.end(), c2.begin())</code> without having to think on the right version of begin and end.</p> <p>This is the general approach in the STL. Remember of <code>operator[]</code>... Having in the mind that the containers are to be used with the algorithms, this is plausible. Although it's also noticeable that in some cases you might still need to define an iterator with a matching version (<code>iterator</code> or <code>const_iterator</code>).</p> <p>Well, this is just what comes up to my mind right now. I'm not sure how convincing it is...</p> <p><em>Side note</em>: The correct way to use constant iterators is through the <code>const_iterator</code> typedef.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload