2010-03-28 16:08:35 +00:00
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=US-ASCII" >
< title > Terminology and style guidelines</ title >
2010-07-13 20:31:40 +00:00
< link rel = "stylesheet" href = "../../../../../doc/src/boostbook.css" type = "text/css" >
< meta name = "generator" content = "DocBook XSL Stylesheets V1.75.2" >
2010-03-28 16:08:35 +00:00
< link rel = "home" href = "../index.html" title = "Chapter 1. Range 2.0" >
< link rel = "up" href = "../index.html" title = "Chapter 1. Range 2.0" >
2010-04-28 16:09:03 +00:00
< link rel = "prev" href = "reference/extending/method_3/method_3_2.html" title = "Method 3.2: Implement a Range Adaptor with arguments" >
2010-12-22 22:31:33 +00:00
< link rel = "next" href = "headers.html" title = "Library Headers" >
2010-03-28 16:08:35 +00:00
</ head >
< body bgcolor = "white" text = "black" link = "#0000FF" vlink = "#840084" alink = "#0000FF" >
< table cellpadding = "2" width = "100%" >< tr >
< td valign = "top" >< img alt = "Boost C++ Libraries" width = "277" height = "86" src = "../../../../../boost.png" ></ td >
< td align = "center" >< a href = "../../../../../index.html" > Home</ a ></ td >
2010-07-13 20:31:40 +00:00
< td align = "center" >< a href = "../../../../../libs/libraries.htm" > Libraries</ a ></ td >
2010-03-28 16:08:35 +00:00
< td align = "center" >< a href = "http://www.boost.org/users/people.html" > People</ a ></ td >
< td align = "center" >< a href = "http://www.boost.org/users/faq.html" > FAQ</ a ></ td >
< td align = "center" >< a href = "../../../../../more/index.htm" > More</ a ></ td >
</ tr ></ table >
< hr >
< div class = "spirit-nav" >
2010-12-22 22:31:33 +00:00
< a accesskey = "p" href = "reference/extending/method_3/method_3_2.html" >< img src = "../../../../../doc/src/images/prev.png" alt = "Prev" ></ a >< a accesskey = "u" href = "../index.html" >< img src = "../../../../../doc/src/images/up.png" alt = "Up" ></ a >< a accesskey = "h" href = "../index.html" >< img src = "../../../../../doc/src/images/home.png" alt = "Home" ></ a >< a accesskey = "n" href = "headers.html" >< img src = "../../../../../doc/src/images/next.png" alt = "Next" ></ a >
2010-03-28 16:08:35 +00:00
</ div >
2010-07-13 20:31:40 +00:00
< div class = "section" >
2010-03-28 16:08:35 +00:00
< div class = "titlepage" >< div >< div >< h2 class = "title" style = "clear: both" >
2010-12-22 22:31:33 +00:00
< a name = "range.style_guide" ></ a >< a class = "link" href = "style_guide.html" title = "Terminology and style guidelines" > Terminology and style guidelines</ a >
2010-03-28 16:08:35 +00:00
</ h2 ></ div ></ div ></ div >
< p >
The use of a consistent terminology is as important for < a class = "link" href = "concepts.html" title = "Range Concepts" > Ranges</ a >
and range-based algorithms as it is for iterators and iterator-based algorithms.
If a conventional set of names are adopted, we can avoid misunderstandings
and write generic function prototypes that are < span class = "bold" >< strong >< span class = "emphasis" >< em > self-documenting</ em ></ span ></ strong ></ span > .
</ p >
< p >
Since ranges are characterized by a specific underlying iterator type, we get
a type of range for each type of iterator. Hence we can speak of the following
types of ranges:
</ p >
< div class = "itemizedlist" >< ul class = "itemizedlist" type = "disc" >
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
< p class = "simpara" >
2010-07-13 20:31:40 +00:00
< span class = "bold" >< strong >< span class = "emphasis" >< em > Value access</ em ></ span ></ strong ></ span > category:
2010-12-22 22:31:33 +00:00
</ p >
< div class = "itemizedlist" >< ul class = "itemizedlist" type = "circle" >
2010-03-28 16:08:35 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
Readable Range
</ li >
2010-03-28 16:08:35 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
Writeable Range
</ li >
2010-03-28 16:08:35 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
Swappable Range
</ li >
2010-03-28 16:08:35 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
Lvalue Range
</ li >
2010-03-28 16:08:35 +00:00
</ ul ></ div >
2010-12-22 22:31:33 +00:00
</ li >
2010-03-28 16:08:35 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
< p class = "simpara" >
2010-07-13 20:31:40 +00:00
< span class = "bold" >< strong >< span class = "emphasis" >< em > Traversal</ em ></ span ></ strong ></ span > category:
2010-12-22 22:31:33 +00:00
</ p >
< div class = "itemizedlist" >< ul class = "itemizedlist" type = "circle" >
2010-07-13 20:31:40 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
< a class = "link" href = "concepts/single_pass_range.html" title = "Single Pass Range" > Single Pass Range</ a >
</ li >
2010-07-13 20:31:40 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
< a class = "link" href = "concepts/forward_range.html" title = "Forward Range" > Forward Range</ a >
</ li >
2010-07-13 20:31:40 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
< a class = "link" href = "concepts/bidirectional_range.html" title = "Bidirectional Range" > Bidirectional Range</ a >
</ li >
2010-07-13 20:31:40 +00:00
< li class = "listitem" >
2010-12-22 22:31:33 +00:00
< a class = "link" href = "concepts/random_access_range.html" title = "Random Access Range" > Random Access Range</ a >
</ li >
2010-03-28 16:08:35 +00:00
</ ul ></ div >
2010-12-22 22:31:33 +00:00
</ li >
2010-03-28 16:08:35 +00:00
</ ul ></ div >
< p >
2010-04-05 17:36:10 +00:00
Notice how we have used the categories from the < a href = "../../../../../libs/iterator/doc/new-iter-concepts.html" target = "_top" > new
2010-03-28 16:08:35 +00:00
style iterators</ a > .
</ p >
< p >
Notice that an iterator (and therefore an range) has one < span class = "bold" >< strong >< span class = "emphasis" >< em > traversal</ em ></ span ></ strong ></ span >
property and one or more properties from the < span class = "bold" >< strong >< span class = "emphasis" >< em > value
access</ em ></ span ></ strong ></ span > category. So in reality we will mostly talk about
mixtures such as
</ p >
< div class = "itemizedlist" >< ul class = "itemizedlist" type = "disc" >
< li class = "listitem" >
2010-07-13 20:31:40 +00:00
Random Access Readable Writeable Range
</ li >
2010-03-28 16:08:35 +00:00
< li class = "listitem" >
2010-07-13 20:31:40 +00:00
Forward Lvalue Range
</ li >
2010-03-28 16:08:35 +00:00
</ ul ></ div >
< p >
By convention, we should always specify the < span class = "bold" >< strong >< span class = "emphasis" >< em > traversal</ em ></ span ></ strong ></ span >
property first as done above. This seems reasonable since there will only be
one < span class = "bold" >< strong >< span class = "emphasis" >< em > traversal</ em ></ span ></ strong ></ span > property,
but perhaps many < span class = "bold" >< strong >< span class = "emphasis" >< em > value access</ em ></ span ></ strong ></ span >
properties.
</ p >
< p >
It might, however, be reasonable to specify only one category if the other
2010-04-28 16:09:03 +00:00
category does not matter. For example, the < a class = "link" href = "reference/utilities/iterator_range.html" title = "Class iterator_range" >< code class = "computeroutput" >< span class = "identifier" > iterator_range</ span ></ code ></ a > can be constructed
2010-03-28 16:08:35 +00:00
from a Forward Range. This means that we do not care about what < span class = "bold" >< strong >< span class = "emphasis" >< em > value
access</ em ></ span ></ strong ></ span > properties the Range has. Similarly, a Readable
Range will be one that has the lowest possible < span class = "bold" >< strong >< span class = "emphasis" >< em > traversal</ em ></ span ></ strong ></ span >
property (Single Pass).
</ p >
< p >
As another example, consider how we specify the interface of < code class = "computeroutput" >< span class = "identifier" > std</ span >< span class = "special" > ::</ span >< span class = "identifier" > sort</ span >< span class = "special" > ()</ span ></ code > . Algorithms are usually more cumbersome to
specify the interface of since both < span class = "bold" >< strong >< span class = "emphasis" >< em > traversal</ em ></ span ></ strong ></ span >
and < span class = "bold" >< strong >< span class = "emphasis" >< em > value access</ em ></ span ></ strong ></ span > properties
must be exactly defined. The iterator-based version looks like this:
</ p >
< p >
</ p >
< pre class = "programlisting" >< span class = "keyword" > template</ span >< span class = "special" > < </ span > < span class = "keyword" > class</ span > < span class = "identifier" > RandomAccessTraversalReadableWritableIterator</ span > < span class = "special" > > </ span >
< span class = "keyword" > void</ span > < span class = "identifier" > sort</ span >< span class = "special" > (</ span > < span class = "identifier" > RandomAccessTraversalReadableWritableIterator</ span > < span class = "identifier" > first</ span >< span class = "special" > ,</ span >
< span class = "identifier" > RandomAccessTraversalReadableWritableIterator</ span > < span class = "identifier" > last</ span > < span class = "special" > );</ span >
</ pre >
< p >
</ p >
< p >
For ranges the interface becomes
</ p >
< p >
</ p >
< pre class = "programlisting" >< span class = "keyword" > template</ span >< span class = "special" > < </ span > < span class = "keyword" > class</ span > < span class = "identifier" > RandomAccessReadableWritableRange</ span > < span class = "special" > > </ span >
< span class = "keyword" > void</ span > < span class = "identifier" > sort</ span >< span class = "special" > (</ span > < span class = "identifier" > RandomAccessReadableWritableRange</ span >< span class = "special" > & </ span > < span class = "identifier" > r</ span > < span class = "special" > );</ span >
</ pre >
< p >
</ p >
</ div >
< table xmlns:rev = "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width = "100%" >< tr >
< td align = "left" ></ td >
< td align = "right" >< div class = "copyright-footer" > Copyright © 2003 -2010 Thorsten Ottosen, Neil Groves< p >
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at < a href = "http://www.boost.org/LICENSE_1_0.txt" target = "_top" > http://www.boost.org/LICENSE_1_0.txt</ a > )
</ p >
</ div ></ td >
</ tr ></ table >
< hr >
< div class = "spirit-nav" >
2010-12-22 22:31:33 +00:00
< a accesskey = "p" href = "reference/extending/method_3/method_3_2.html" >< img src = "../../../../../doc/src/images/prev.png" alt = "Prev" ></ a >< a accesskey = "u" href = "../index.html" >< img src = "../../../../../doc/src/images/up.png" alt = "Up" ></ a >< a accesskey = "h" href = "../index.html" >< img src = "../../../../../doc/src/images/home.png" alt = "Home" ></ a >< a accesskey = "n" href = "headers.html" >< img src = "../../../../../doc/src/images/next.png" alt = "Next" ></ a >
2010-03-28 16:08:35 +00:00
</ div >
</ body >
</ html >