mirror of
https://github.com/boostorg/range.git
synced 2025-06-25 20:12:13 +02:00
Compare commits
81 Commits
boost-1.32
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
f98d3eeb30 | |||
51650f1aa2 | |||
aeb47120e3 | |||
22b7b4ec8e | |||
a933622ae1 | |||
f49be0b382 | |||
007117cefb | |||
73bb3d899a | |||
4a8987865e | |||
f885495565 | |||
dc34cd6079 | |||
5850d7ce3e | |||
554f832234 | |||
dc96b440be | |||
1ac9efbd6a | |||
d2f0c15826 | |||
ae953cda6b | |||
b22773b2e3 | |||
e50a544c2a | |||
4b362a9cff | |||
c75dc3ae02 | |||
fa03f39333 | |||
6478f85444 | |||
51f7fe9878 | |||
c08103b1c5 | |||
a2b6c3f5ec | |||
e76e9cda28 | |||
cd6a5e6a7f | |||
e82a7fab5d | |||
7311fb528a | |||
8a998c64d8 | |||
2bc8622027 | |||
1c4fcbee6f | |||
24a881ef85 | |||
8db1f867f9 | |||
e5ddbb4bbc | |||
f6b183140f | |||
1b3c6f1c81 | |||
d509beb073 | |||
0965a46d9c | |||
5771d953ea | |||
898aae2c85 | |||
75667cc53d | |||
16989df4d6 | |||
4b89a3e223 | |||
c2ddc197aa | |||
0ab5e6e60d | |||
34e3275c99 | |||
b2e9200529 | |||
c17afe8d03 | |||
a5a74c161f | |||
d77dbb2d0b | |||
c5d1b4a62a | |||
9b1cdde025 | |||
f5aad599ef | |||
5843a9fd3f | |||
918b652291 | |||
a02b6c0f74 | |||
b358ea0773 | |||
6d4740bcab | |||
25ebab429d | |||
4cca4fac2f | |||
6b9919ae4b | |||
1c8f27535d | |||
7d5596abd6 | |||
4524abb615 | |||
bf5ca9612c | |||
844bfc5a2d | |||
d8fb9a991c | |||
caa13c7387 | |||
64cd26106a | |||
1451d487e1 | |||
92c5ce8ffa | |||
e5d4c1c376 | |||
fbd60395d6 | |||
d82d9b9680 | |||
ed09875157 | |||
92c375e173 | |||
eeb7bf0fe0 | |||
b3d4845ba6 | |||
6dd15529f6 |
File diff suppressed because it is too large
Load Diff
141
doc/example.cpp
Normal file
141
doc/example.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
#include <boost/range.hpp>
|
||||
#include <iterator> // for std::iterator_traits, std::distance()
|
||||
|
||||
namespace Foo
|
||||
{
|
||||
//
|
||||
// Our sample UDT. A 'Pair'
|
||||
// will work as a range when the stored
|
||||
// elements are iterators.
|
||||
//
|
||||
template< class T >
|
||||
struct Pair
|
||||
{
|
||||
T first, last;
|
||||
};
|
||||
|
||||
} // namespace 'Foo'
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//
|
||||
// Specialize metafunctions. We must include the range.hpp header.
|
||||
// We must open the 'boost' namespace.
|
||||
//
|
||||
/*
|
||||
template< class T >
|
||||
struct range_value< Foo::Pair<T> >
|
||||
{
|
||||
typedef typename std::iterator_traits<T>::value_type type;
|
||||
};
|
||||
*/
|
||||
|
||||
template< class T >
|
||||
struct range_iterator< Foo::Pair<T> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct range_const_iterator< Foo::Pair<T> >
|
||||
{
|
||||
//
|
||||
// Remark: this is defined similar to 'range_iterator'
|
||||
// because the 'Pair' type does not distinguish
|
||||
// between an iterator and a const_iterator.
|
||||
//
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
/*
|
||||
template< class T >
|
||||
struct range_difference< Foo::Pair<T> >
|
||||
{
|
||||
typedef typename std::iterator_traits<T>::difference_type type;
|
||||
};
|
||||
*/
|
||||
|
||||
template< class T >
|
||||
struct range_size< Foo::Pair<T> >
|
||||
{
|
||||
int static_assertion[ sizeof( std::size_t ) >=
|
||||
sizeof( typename range_difference< Foo::Pair<T> >::type ) ];
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
namespace Foo
|
||||
{
|
||||
//
|
||||
// The required functions. These should be defined in
|
||||
// the same namespace as 'Pair', in this case
|
||||
// in namespace 'Foo'.
|
||||
//
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_begin( Pair<T>& x )
|
||||
{
|
||||
return x.first;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_begin( const Pair<T>& x )
|
||||
{
|
||||
return x.first;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_end( Pair<T>& x )
|
||||
{
|
||||
return x.last;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline T boost_range_end( const Pair<T>& x )
|
||||
{
|
||||
return x.last;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline typename boost::range_size< Pair<T> >::type
|
||||
boost_range_size( const Pair<T>& x )
|
||||
{
|
||||
return std::distance(x.first,x.last);
|
||||
}
|
||||
|
||||
} // namespace 'Foo'
|
||||
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::vector<int>::iterator iter;
|
||||
std::vector<int> vec;
|
||||
vec.push_back( 42 );
|
||||
Foo::Pair<iter> pair = { vec.begin(), vec.end() };
|
||||
const Foo::Pair<iter>& cpair = pair;
|
||||
//
|
||||
// Notice that we call 'begin' etc with qualification.
|
||||
//
|
||||
iter i = boost::begin( pair );
|
||||
iter e = boost::end( pair );
|
||||
i = boost::begin( cpair );
|
||||
e = boost::end( cpair );
|
||||
boost::range_size< Foo::Pair<iter> >::type s = boost::size( pair );
|
||||
s = boost::size( cpair );
|
||||
boost::range_const_reverse_iterator< Foo::Pair<iter> >::type
|
||||
ri = boost::rbegin( cpair ),
|
||||
re = boost::rend( cpair );
|
||||
|
||||
//
|
||||
// Test metafunctions
|
||||
//
|
||||
|
||||
boost::range_value< Foo::Pair<iter> >::type
|
||||
v = *boost::begin(pair);
|
||||
|
||||
boost::range_difference< Foo::Pair<iter> >::type
|
||||
d = boost::end(pair) - boost::begin(pair);
|
||||
}
|
||||
|
@ -24,8 +24,13 @@
|
||||
<li >
|
||||
<a href="../test/string.cpp" target="_self" ><code >string.cpp</code></a>
|
||||
</li>
|
||||
shows how to implement a container version of <code >std::find()</code> that
|
||||
shows how to implement a container version of <code >std::find()</code> that
|
||||
works with <code >char[],wchar_t[],char*,wchar_t*.</code>
|
||||
<p>
|
||||
<b>Warning:</b><i> support for null-terminated strings is deprecated and will
|
||||
disappear in the next Boost release (1.34). </i>
|
||||
</p>
|
||||
|
||||
<li >
|
||||
<a href="../test/algorithm_example.cpp" target="_self" ><code >algorithm_example.cpp</code></a>
|
||||
|
||||
|
76
doc/faq.html
76
doc/faq.html
@ -20,36 +20,36 @@
|
||||
<h2 >FAQ</h2> <a name="FAQ" ></a>
|
||||
<ol >
|
||||
<li >
|
||||
<i>Why is there no difference between <code >range_iterator<C>::type</code>
|
||||
<i>Why is there no difference between <code >range_iterator<C>::type</code>
|
||||
and <code >range_const_iterator<C>::type</code> for <code>std::pair<iterator, iterator></code></i>.
|
||||
</li>
|
||||
<p >
|
||||
In general it is not possible nor desirable to find a corresponding <code >const_iterator</code>.
|
||||
When it is possible to come up with one, the client might choose to construct a <code >std::pair<const_iterator,const_iterator></code>
|
||||
In general it is not possible nor desirable to find a corresponding <code >const_iterator</code>.
|
||||
When it is possible to come up with one, the client might choose to construct a <code >std::pair<const_iterator,const_iterator></code>
|
||||
object.
|
||||
</p>
|
||||
<p>
|
||||
Note that an <a href="utility_class.html#iter_range">iterator_range</a>
|
||||
is somewhat more convenient than a <code>pair</code> and that a <a
|
||||
href="utility_class.html#sub_range"><code>sub_range</code></a> do
|
||||
Note that an <a href="utility_class.html#iter_range">iterator_range</a>
|
||||
is somewhat more convenient than a <code>pair</code> and that a <a
|
||||
href="utility_class.html#sub_range"><code>sub_range</code></a> does
|
||||
propagate const-ness. </p>
|
||||
|
||||
|
||||
<li >
|
||||
<i>Why is there not supplied more types or more functions?</i>
|
||||
<p >
|
||||
The library has been kept small because its current interface will
|
||||
The library has been kept small because its current interface will
|
||||
serve most
|
||||
purposes. If and when a genuine need arises for more functionality, it can be
|
||||
purposes. If and when a genuine need arises for more functionality, it can be
|
||||
implemented.
|
||||
</p>
|
||||
</li>
|
||||
<li >
|
||||
<i>How should I implement generic algorithms for ranges?</i>
|
||||
<p >
|
||||
One should always start with a generic algorithm that takes two iterators (or
|
||||
more) as input. Then use Boost.Range to build handier versions on top of the
|
||||
iterator based algorithm. Please notice that once the range version of the
|
||||
algorithm is done, it makes sense <i>not</i> to expose the iterator version in
|
||||
One should always start with a generic algorithm that takes two iterators (or
|
||||
more) as input. Then use Boost.Range to build handier versions on top of the
|
||||
iterator based algorithm. Please notice that once the range version of the
|
||||
algorithm is done, it makes sense <i>not</i> to expose the iterator version in
|
||||
the public interface.
|
||||
</p>
|
||||
</li>
|
||||
@ -57,59 +57,59 @@
|
||||
<i>Why is there no Incrementable Range concept?</i>
|
||||
<p>
|
||||
Even though we speak of incrementable iterators, it would not make
|
||||
much sense for ranges; for example, we cannot determine the size and
|
||||
emptiness of a range since we cannot even compare
|
||||
its iterators.
|
||||
much sense for ranges; for example, we cannot determine the size and
|
||||
emptiness of a range since we cannot even compare
|
||||
its iterators.
|
||||
</p>
|
||||
<p>
|
||||
Note also that incrementable iterators are derived from output
|
||||
Note also that incrementable iterators are derived from output
|
||||
iterators and so there exist no output range.
|
||||
</p>
|
||||
</li>
|
||||
</li>
|
||||
<!--
|
||||
<li>
|
||||
<i>Should I use qualified syntax, for example
|
||||
<blockquote><pre>
|
||||
<span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>); </span>
|
||||
</pre></blockquote>
|
||||
instead of
|
||||
instead of
|
||||
<blockquote>
|
||||
<pre><span class=keyword>using </span><span class=keyword>namespace </span><span class=identifier>boost</span><span class=special>;</span>
|
||||
<span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>)</span></pre></blockquote>
|
||||
when calling functions in this library? If so, can I still rely on argument
|
||||
when calling functions in this library? If so, can I still rely on argument
|
||||
dependent lookup (ADL) to kick in?</i>
|
||||
<p>
|
||||
The answer to the first question is that "it's up to you". The
|
||||
answer to the second question is Yes. Normally qualified syntax
|
||||
disables ADL, but the functions are implemented in a special
|
||||
manner that preserves ADL properties. The trick was explained by
|
||||
Daniel Frey on comp.lang.std.c++ in the thread "Whence Swap" and
|
||||
The answer to the first question is that "it's up to you". The
|
||||
answer to the second question is Yes. Normally qualified syntax
|
||||
disables ADL, but the functions are implemented in a special
|
||||
manner that preserves ADL properties. The trick was explained by
|
||||
Daniel Frey on comp.lang.std.c++ in the thread "Whence Swap" and
|
||||
it is best explained by some code: <blockquote>
|
||||
<pre>
|
||||
<span class=keyword>namespace </span><span class=identifier>boost</span>
|
||||
<span class=special>{
|
||||
</span><span class=keyword>namespace </span><span class=identifier>range_detail
|
||||
</span><span class=keyword>namespace </span><span class=identifier>range_detail
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>:</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
||||
</span><span class=special>{ </span><span class=comment>/* normal implementation */ </span><span class=special>}
|
||||
</span><span class=special>}
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=special>}
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>T</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>r </span><span class=special>)
|
||||
</span><span class=special>{
|
||||
</span><span class=comment>//
|
||||
</span><span class=comment>//
|
||||
// Create ADL hook
|
||||
//
|
||||
</span><span class=keyword>using </span><span class=identifier>range_detail</span><span class=special>::</span><span class=identifier>begin</span><span class=special>;
|
||||
</span><span class=keyword>return </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
|
||||
//
|
||||
</span><span class=keyword>using </span><span class=identifier>range_detail</span><span class=special>::</span><span class=identifier>begin</span><span class=special>;
|
||||
</span><span class=keyword>return </span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>r </span><span class=special>);
|
||||
</span><span class=special>}</span>
|
||||
<span class=special>} </span>
|
||||
<span class=special>} </span>
|
||||
</pre>
|
||||
</blockquote>
|
||||
Cool indeed!
|
||||
</blockquote>
|
||||
Cool indeed!
|
||||
</p>
|
||||
-->
|
||||
-->
|
||||
|
||||
</ol>
|
||||
|
||||
|
@ -141,6 +141,11 @@
|
||||
<td ><a href="utility_class.html#sub_range" >sub_range</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/concepts.hpp></code></td>
|
||||
<td ><a href="range.html#concept_checking" >concept checks</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<br
|
||||
|
@ -52,11 +52,16 @@ C++ standard: <blockquote>
|
||||
<li> Pavel Vozenilek for help with porting the library
|
||||
<li> Jonathan Turkanis and John Torjo for help with documentation
|
||||
<li> Hartmut Kaiser for being review manager
|
||||
<li> Jonathan Turkanis for porting the lib (as far sa possible) to
|
||||
vc6 and vc7.
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
The concept checks and their documentation was provided by Daniel Walker.
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
(C) Copyright Thorsten Ottosen 2003-2006
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
@ -18,36 +18,36 @@
|
||||
|
||||
<h2>Introduction</h2>
|
||||
<p>
|
||||
Generic algorithms have so far been specified in terms of two or more
|
||||
iterators. Two iterators would together form a range of values that the
|
||||
Generic algorithms have so far been specified in terms of two or more
|
||||
iterators. Two iterators would together form a range of values that the
|
||||
algorithm could work on. This leads to a very general interface, but also
|
||||
to a somewhat clumsy use of the algorithms with redundant specification
|
||||
of container names. Therefore we would like to raise the abstraction level
|
||||
for algorithms so they specify their interface in terms of <a
|
||||
for algorithms so they specify their interface in terms of <a
|
||||
href=range.html>Ranges</a> as much as possible.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
The most common form of ranges we are used to work with is standard library
|
||||
The most common form of ranges we are used to work with is standard library
|
||||
containers. However, one
|
||||
often finds it desirable to extend that code to work with other types that
|
||||
often finds it desirable to extend that code to work with other types that
|
||||
offer
|
||||
enough functionality to satisfy the needs of the generic code
|
||||
<i>if a suitable layer of indirection is applied </i>. For
|
||||
enough functionality to satisfy the needs of the generic code
|
||||
<i>if a suitable layer of indirection is applied </i>. For
|
||||
example, raw arrays are often suitable for use with generic code that
|
||||
works with containers, provided a suitable adapter is used. Likewise, null
|
||||
terminated strings can be treated as containers of characters, if suitably
|
||||
adapted.
|
||||
</p>
|
||||
|
||||
works with containers, provided a suitable adapter is used. Likewise, null
|
||||
terminated strings can be treated as containers of characters, if suitably
|
||||
adapted.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This library therefore provides the means to adapt standard-like
|
||||
This library therefore provides the means to adapt standard-like
|
||||
containers,
|
||||
null terminated strings, <code>std::pairs</code> of iterators, and raw
|
||||
arrays (and more), such that the same generic code can work with them all.
|
||||
The basic idea is to add another layer of indirection using <a
|
||||
href="../../mpl/doc/index.html#metafunctions">metafunctions</a> and
|
||||
free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
null terminated strings, <code>std::pairs</code> of iterators, and raw
|
||||
arrays (and more), such that the same generic code can work with them all.
|
||||
The basic idea is to add another layer of indirection using <a
|
||||
href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a> and
|
||||
free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
</p>
|
||||
|
||||
<p >
|
||||
@ -61,15 +61,19 @@ free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
</li>
|
||||
<li >
|
||||
correct handling of null-terminated strings
|
||||
<p>
|
||||
<b>Warning:</b><i> support for null-terminated strings is deprecated and will
|
||||
disappear in the next Boost release (1.34). </i>
|
||||
</p>
|
||||
</li>
|
||||
<li >
|
||||
safe use of built-in arrays (for legacy code; why else would you use
|
||||
safe use of built-in arrays (for legacy code; why else would you use
|
||||
built-in arrays?) </li>
|
||||
|
||||
</ul>
|
||||
</p>
|
||||
<p >
|
||||
Below are given a small example (the complete example can be found <a href="../test/algorithm_example.cpp" target="_self" >here</a>
|
||||
Below are given a small example (the complete example can be found <a href="../test/algorithm_example.cpp" target="_self" >here</a>
|
||||
):
|
||||
<blockquote>
|
||||
<pre >
|
||||
@ -83,7 +87,7 @@ free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>value </span><span class=special>);
|
||||
</span><span class=special>}
|
||||
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardReadableRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>T </span><span class=special>>
|
||||
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_const_iterator</span><span class=special>< </span><span
|
||||
class=identifier>ForwardReadableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
@ -91,7 +95,7 @@ class=identifier>ForwardReadableRange </span><span class=special>>::</span><s
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>find</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>value </span><span class=special>);
|
||||
</span><span class=special>}
|
||||
|
||||
|
||||
</span><span class=comment>//
|
||||
// replace first value and return its index
|
||||
//
|
||||
@ -100,7 +104,7 @@ class=identifier>ForwardReadableRange </span><span class=special>>::</span><s
|
||||
</span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>ForwardReadableWriteableRange</span><span class=special>& </span><span class=identifier>c</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>value</span><span class=special>, </span><span class=keyword>const </span><span class=identifier>T</span><span class=special>& </span><span class=identifier>replacement </span><span class=special>)
|
||||
</span><span class=special>{
|
||||
</span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_iterator</span><span class=special>< </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>found </span><span class=special>= </span><span class=identifier>find</span><span class=special>( </span><span class=identifier>c</span><span class=special>, </span><span class=identifier>value </span><span class=special>);
|
||||
|
||||
|
||||
</span><span class=keyword>if</span><span class=special>( </span><span class=identifier>found </span><span class=special>!= </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>c </span><span class=special>) </span><span class=special>)
|
||||
</span><span class=special>*</span><span class=identifier>found </span><span class=special>= </span><span class=identifier>replacement</span><span class=special>;
|
||||
</span><span class=keyword>return </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>distance</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>c </span><span class=special>), </span><span class=identifier>found </span><span class=special>);
|
||||
@ -111,30 +115,30 @@ class=identifier>ForwardReadableRange </span><span class=special>>::</span><s
|
||||
//
|
||||
</span><span class=keyword>const </span><span class=keyword>int </span><span class=identifier>N </span><span class=special>= </span><span class=number>5</span><span class=special>;
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=keyword>int</span><span class=special>> </span><span class=identifier>my_vector</span><span class=special>;
|
||||
</span><span class=keyword>int </span><span class=identifier>values</span><span class=special>[] </span><span class=special>= </span><span class=special>{ </span><span class=number>1</span><span class=special>,</span><span class=number>2</span><span class=special>,</span><span class=number>3</span><span class=special>,</span><span class=number>4</span><span class=special>,</span><span class=number>5</span><span class=special>,</span><span class=number>6</span><span class=special>,</span><span class=number>7</span><span class=special>,</span><span class=number>8</span><span class=special>,</span><span class=number>9 </span><span class=special>};
|
||||
</span><span class=keyword>int </span><span class=identifier>values</span><span class=special>[] </span><span class=special>= </span><span class=special>{ </span><span class=number>1</span><span class=special>,</span><span class=number>2</span><span class=special>,</span><span class=number>3</span><span class=special>,</span><span class=number>4</span><span class=special>,</span><span class=number>5</span><span class=special>,</span><span class=number>6</span><span class=special>,</span><span class=number>7</span><span class=special>,</span><span class=number>8</span><span class=special>,</span><span class=number>9 </span><span class=special>};
|
||||
</span>
|
||||
<span class=identifier>my_vector</span><span class=special>.</span><span
|
||||
<span class=identifier>my_vector</span><span class=special>.</span><span
|
||||
class=identifier>assign</span><span class=special>( </span><span class=identifier>values</span><span class=special>, </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>end</span><span class=special>( </span><span class=identifier>values </span><span class=special>) </span><span class=special>);</span>
|
||||
</span><span class=keyword>typedef </span><span class=identifier>std</span><span class=special>::</span><span class=identifier>vector</span><span class=special><</span><span class=keyword>int</span><span class=special>>::</span><span class=identifier>iterator </span><span class=identifier>iterator</span><span class=special>;
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special><</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>iterator</span><span class=special>> </span><span class=identifier>my_view</span><span class=special>( </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>my_vector </span><span class=special>),
|
||||
</span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>begin</span><span class=special>( </span><span class=identifier>my_vector </span><span class=special>) </span><span class=special>+ </span><span class=identifier>N </span><span class=special>);
|
||||
</span><span class=keyword>char </span><span class=identifier>str_val</span><span class=special>[] </span><span class=special>= </span><span class=string>"a string"</span><span class=special>;
|
||||
</span><span class=keyword>char</span><span class=special>* </span><span class=identifier>str </span><span class=special>= </span><span class=identifier>str_val</span><span class=special>;
|
||||
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_vector</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>)
|
||||
</span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_view</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>)
|
||||
</span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>str</span><span class=special>, </span><span class=literal>'a'</span><span class=special>, </span><span class=literal>'b' </span><span class=special>);
|
||||
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_vector</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>);
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>my_view</span><span class=special>, </span><span class=number>4</span><span class=special>, </span><span class=number>2 </span><span class=special>);
|
||||
</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>cout </span><span class=special><< </span><span class=identifier>my_generic_replace</span><span class=special>( </span><span class=identifier>str</span><span class=special>, </span><span class=literal>'a'</span><span class=special>, </span><span class=literal>'b' </span><span class=special>);
|
||||
</span>
|
||||
<span class=comment>// prints '3', '5' and '0' </span>
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
By using the free-standing functions and <a
|
||||
href="../../mpl/doc/index.html#metafunctions">metafunctions</a>, the code automatically
|
||||
works for all the types supported by this library; now and in the future.
|
||||
By using the free-standing functions and <a
|
||||
href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a>, the code automatically
|
||||
works for all the types supported by this library; now and in the future.
|
||||
Notice that we have to
|
||||
provide two version of <code >find()</code> since we cannot forward a non-const
|
||||
rvalue with reference arguments (see this article about <a href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_self" >The
|
||||
provide two version of <code >find()</code> since we cannot forward a non-const
|
||||
rvalue with reference arguments (see this article about <a href="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2002/n1385.htm" target="_self" >The
|
||||
Forwarding Problem</a> ).
|
||||
|
||||
</p>
|
||||
|
@ -29,6 +29,10 @@ href="http://boost.sourceforge.net/regression-logs/developer/range.html">here</a
|
||||
template partial specialization. For non-conforming compilers there might be a
|
||||
chance that it works anyway thanks to workarounds in the type traits library.
|
||||
</p>
|
||||
<pp>
|
||||
Visual C++ 6/7.0 has a limited support for arrays: as long as the arrays are
|
||||
of built-in type it should work.
|
||||
</p>
|
||||
<p >
|
||||
Notice also that some compilers cannot do function template ordering properly.
|
||||
In that case one must rely of <a
|
||||
|
220
doc/range.html
220
doc/range.html
@ -36,6 +36,8 @@
|
||||
<a href="#bidirectional_range">Bidirectional Range</a>
|
||||
<li>
|
||||
<a href="#random_access_range">Random Access Range</a>
|
||||
<li>
|
||||
<a href="#concept_checking">Concept Checking</a>
|
||||
</ul>
|
||||
|
||||
<a name="overview"></a>
|
||||
@ -44,16 +46,16 @@
|
||||
|
||||
<p>
|
||||
A Range is a <i>concept</i> similar to the STL <a
|
||||
href="http://www.sgi.com/Technology/STL/Container.html">Container</a> concept. A
|
||||
Range provides iterators for accessing a closed-open range
|
||||
href="http://www.sgi.com/Technology/STL/Container.html">Container</a> concept. A
|
||||
Range provides iterators for accessing a half-open range
|
||||
<code>[first,one_past_last)</code> of elements and provides
|
||||
information about the number of elements in the Range. However, a Range has
|
||||
fewer requirements than a Container.
|
||||
</p>
|
||||
information about the number of elements in the Range. However, a Range has
|
||||
fewer requirements than a Container.
|
||||
</p>
|
||||
<p>
|
||||
The motivation for the Range concept is
|
||||
that there are many useful Container-like types that do not meet the full
|
||||
requirements of Container, and many algorithms that can be written with this
|
||||
The motivation for the Range concept is
|
||||
that there are many useful Container-like types that do not meet the full
|
||||
requirements of Container, and many algorithms that can be written with this
|
||||
reduced set of requirements. In particular, a Range does not necessarily
|
||||
|
||||
<ul>
|
||||
@ -67,23 +69,26 @@
|
||||
-->
|
||||
</ul>
|
||||
|
||||
|
||||
Because of the second requirement, a Range object must be passed by
|
||||
|
||||
Because of the second requirement, a Range object must be passed by
|
||||
(const or non-const) reference in generic code.
|
||||
|
||||
</p>
|
||||
<p>
|
||||
The operations that can be performed on a Range is dependent on the
|
||||
<a href="../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal">traversal
|
||||
The operations that can be performed on a Range is dependent on the
|
||||
<a href="../../iterator/doc/new-iter-concepts.html#iterator-traversal-concepts-lib-iterator-traversal">traversal
|
||||
category</a> of the underlying iterator type. Therefore
|
||||
the range concepts are named to reflect which traversal category its
|
||||
the range concepts are named to reflect which traversal category its
|
||||
iterators support. See also <a href="style.html">terminology and style guidelines.</a>
|
||||
for more information about naming of ranges.</p>
|
||||
|
||||
|
||||
<p> The concepts described below specifies associated types as
|
||||
<a href="../../mpl/doc/index.html#metafunctions">metafunctions</a> and all
|
||||
<a href="../../mpl/doc/refmanual/metafunction.html">metafunctions</a> and all
|
||||
functions as free-standing functions to allow for a layer of indirection. </p>
|
||||
|
||||
<!--<p><i>Notice that these metafunctions must be defined in namespace </i>
|
||||
<code>boost</code></p>-->
|
||||
|
||||
<hr>
|
||||
<a name="single_pass_range">
|
||||
<H2>Single Pass Range</H2>
|
||||
@ -100,10 +105,10 @@ functions as free-standing functions to allow for a layer of indirection. </p>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<h3>Description</h3>
|
||||
<p>
|
||||
A range X where <code>range_iterator<X>::type</code> is a model of <a
|
||||
A range X where <code>boost::range_iterator<X>::type</code> is a model of <a
|
||||
href="../../iterator/doc/new-iter-concepts.html#single-pass-iterators-lib-single-pass-iterators">
|
||||
Single Pass Iterator</a>
|
||||
|
||||
@ -115,20 +120,20 @@ Single Pass Iterator</a>
|
||||
<table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TD VAlign="top">Value type</TD>
|
||||
<TD VAlign="top"><code>range_value<X>::type</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_value<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of the object stored in a Range.
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Iterator type</TD>
|
||||
<TD VAlign="top"><code>range_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of iterator used to iterate through a Range's elements.
|
||||
The iterator's value type is expected to be the Range's value type. A
|
||||
<TD VAlign="top"><code>boost::range_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of iterator used to iterate through a Range's elements.
|
||||
The iterator's value type is expected to be the Range's value type. A
|
||||
conversion from the iterator type to the const iterator type must exist.
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Const iterator type</TD>
|
||||
<TD VAlign="top"><code>range_const_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">A type of iterator that may be used to examine, but not to
|
||||
<TD VAlign="top"><code>boost::range_const_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">A type of iterator that may be used to examine, but not to
|
||||
modify, a Range's elements.</TD>
|
||||
</TR>
|
||||
<!--
|
||||
@ -154,20 +159,20 @@ Single Pass Iterator</a>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Beginning of range</TD>
|
||||
<TD VAlign="top"><code>begin(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_iterator<X>::type</code>
|
||||
<TD VAlign="top"><code>boost::begin(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>boost::range_const_iterator<X>::type</code>
|
||||
otherwise</TD> </TR>
|
||||
<TR>
|
||||
<TD VAlign="top">End of range</TD>
|
||||
<TD VAlign="top"><code>end(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_iterator<X>::type</code>
|
||||
<TD VAlign="top"><code>boost::end(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>boost::range_const_iterator<X>::type</code>
|
||||
otherwise</TD>
|
||||
</TR>
|
||||
<tr>
|
||||
<TD VAlign="top">Is range empty?</TD>
|
||||
<TD VAlign="top"><code>empty(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::empty(a)</code></TD>
|
||||
<TD VAlign="top">Convertible to <code>bool</code></TD>
|
||||
</TR>
|
||||
</table>
|
||||
@ -180,20 +185,20 @@ otherwise</TD>
|
||||
<TH>Postcondition</TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>begin(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::begin(a)</code></TD>
|
||||
<TD VAlign="top">Returns an iterator pointing to the first element in the Range.</TD>
|
||||
<TD VAlign="top"><code>begin(a)</code> is either dereferenceable or past-the-end.
|
||||
It is past-the-end if and only if <code>size(a) == 0</code>.</TD>
|
||||
<TD VAlign="top"><code>boost::begin(a)</code> is either dereferenceable or past-the-end.
|
||||
It is past-the-end if and only if <code>boost::size(a) == 0</code>.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>end(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::end(a)</code></TD>
|
||||
<TD VAlign="top">Returns an iterator pointing one past the last element in the
|
||||
Range.</TD>
|
||||
<TD VAlign="top"><code>end(a)</code> is past-the-end.</TD>
|
||||
<TD VAlign="top"><code>boost::end(a)</code> is past-the-end.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top"><code>empty(a)</code></TD>
|
||||
<TD VAlign="top">Equivalent to <code>begin(a) == end(a)</code>. (But possibly
|
||||
<TD VAlign="top"><code>boost::empty(a)</code></TD>
|
||||
<TD VAlign="top">Equivalent to <code>boost::begin(a) == boost::end(a)</code>. (But possibly
|
||||
faster.)</TD>
|
||||
<TD VAlign="top"> - </TD>
|
||||
</TR>
|
||||
@ -202,20 +207,20 @@ otherwise</TD>
|
||||
<h3>Complexity guarantees</h3>
|
||||
|
||||
All three functions are at most amortized linear time. For most practical
|
||||
purposes, one can expect <code>begin(a)</code>, <code>end(a)</code> and <code>empty(a)</code>
|
||||
purposes, one can expect <code>boost::begin(a)</code>, <code>boost::end(a)</code> and <code>boost::empty(a)</code>
|
||||
to be amortized constant time.
|
||||
|
||||
<h3>Invariants</h3>
|
||||
<Table border>
|
||||
<TR>
|
||||
<TD VAlign="top">Valid range</TD>
|
||||
<TD VAlign="top">For any Range <code>a</code>, <code>[begin(a),end(a))</code> is
|
||||
a valid range, that is, <code>end(a)</code> is reachable from <code>begin(a)</code>
|
||||
<TD VAlign="top">For any Range <code>a</code>, <code>[boost::begin(a),boost::end(a))</code> is
|
||||
a valid range, that is, <code>boost::end(a)</code> is reachable from <code>boost::begin(a)</code>
|
||||
in a finite number of increments.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Completeness</TD>
|
||||
<TD VAlign="top">An algorithm that iterates through the range <code>[begin(a),end(a))</code>
|
||||
<TD VAlign="top">An algorithm that iterates through the range <code>[boost::begin(a),boost::end(a))</code>
|
||||
will pass through every element of <code>a</code>.</TD>
|
||||
</tr>
|
||||
</table>
|
||||
@ -225,6 +230,11 @@ otherwise</TD>
|
||||
<p>
|
||||
<A href="http://www.sgi.com/Technology/STL/Container.html">Container</A>
|
||||
</p>
|
||||
<p> <a href="boost_range.html#boost::range_value">implementation of
|
||||
metafunctions </a></p>
|
||||
|
||||
<p> <a href="boost_range.html#begin">implementation of
|
||||
functions </a></p>
|
||||
|
||||
<hr>
|
||||
<a name=forward_range><h2>Forward Range</h2>
|
||||
@ -243,7 +253,7 @@ otherwise</TD>
|
||||
|
||||
<h3>Description</h3>
|
||||
<p>
|
||||
A range <code>X</code> where <code>range_iterator<X>::type</code> is a model
|
||||
A range <code>X</code> where <code>boost::range_iterator<X>::type</code> is a model
|
||||
of <a
|
||||
href="../../iterator/doc/new-iter-concepts.html#forward-traversal-iterators-lib-forward-traversal-iterators">Forward Traversal Iterator</a>
|
||||
</p>
|
||||
@ -256,14 +266,14 @@ Range</a>
|
||||
<table cellpadding="5" border="1">
|
||||
<TR>
|
||||
<TD VAlign="top">Distance type</TD>
|
||||
<TD VAlign="top"><code>range_difference<X>::type</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_difference<X>::type</code></TD>
|
||||
<TD VAlign="top">A signed integral type used to represent the distance between
|
||||
two of the Range's iterators. This type must be the same as the iterator's
|
||||
distance type.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Size type</TD>
|
||||
<TD VAlign="top"><code>range_size<X>::type</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_size<X>::type</code></TD>
|
||||
<TD VAlign="top">An unsigned integral type that can represent any nonnegative
|
||||
value of the Range's distance type.</TD>
|
||||
</tr>
|
||||
@ -279,8 +289,8 @@ Range</a>
|
||||
</tr>
|
||||
<TR>
|
||||
<TD VAlign="top">Size of range</TD>
|
||||
<TD VAlign="top"><code>size(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_size<X>::type</code></TD>
|
||||
<TD VAlign="top"><code>boost::size(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_size<X>::type</code></TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
@ -293,29 +303,37 @@ Range</a>
|
||||
<TH>Postcondition</TH>
|
||||
</TR>
|
||||
<tr>
|
||||
<TD VAlign="top"><code>size(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::size(a)</code></TD>
|
||||
<TD VAlign="top">Returns the size of the Range, that is, its number
|
||||
of elements. Note <code>size(a) == 0u</code> is equivalent to
|
||||
<code>empty(a).</code></TD>
|
||||
<TD VAlign="top"><code>size(a) >= 0</TD>
|
||||
of elements. Note <code>boost::size(a) == 0u</code> is equivalent to
|
||||
<code>boost::empty(a).</code></TD>
|
||||
<TD VAlign="top"><code>boost::size(a) >= 0</TD>
|
||||
</TR>
|
||||
</table>
|
||||
|
||||
<h3>Complexity guarantees</h3>
|
||||
|
||||
<p><code>size(a)</code> is at most amortized linear time.</p>
|
||||
<p><code>boost::size(a)</code> is at most amortized linear time.</p>
|
||||
|
||||
<h3>Invariants</h3>
|
||||
<p>
|
||||
<Table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TD VAlign="top">Range size</TD>
|
||||
<TD VAlign="top"><code>size(a)</code> is equal to the distance from <code>begin(a)</code>
|
||||
to <code>end(a)</code>.</TD> </table>
|
||||
<TD VAlign="top"><code>boost::size(a)</code> is equal to the distance from <code>boost::begin(a)</code>
|
||||
to <code>boost::end(a)</code>.</TD> </table>
|
||||
</p>
|
||||
|
||||
<h3>See also</h3>
|
||||
<p> <a href="boost_range.html#boost::range_difference">implementation of
|
||||
metafunctions </a></p>
|
||||
|
||||
<p> <a href="boost_range.html#size">implementation of
|
||||
functions </a></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<a name=bidirectional_range><h2>Bidirectional Range</h2>
|
||||
<a name="bidirectional_range"><h2>Bidirectional Range</h2>
|
||||
|
||||
<h3>Notation</h3>
|
||||
<Table>
|
||||
@ -331,7 +349,7 @@ of elements. Note <code>size(a) == 0u</code> is equivalent to
|
||||
|
||||
<h3>Description</h3> This concept provides access to iterators that traverse in
|
||||
both directions (forward and reverse). The
|
||||
<code>range_iterator<X>::type</code> iterator must meet all of the requirements
|
||||
<code>boost::range_iterator<X>::type</code> iterator must meet all of the requirements
|
||||
of <a
|
||||
href="../../iterator/doc/new-iter-concepts.html#bidirectional-traversal-iterator
|
||||
s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.</a>
|
||||
@ -343,7 +361,7 @@ s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.</a>
|
||||
<Table border>
|
||||
<TR>
|
||||
<TD VAlign="top">Reverse Iterator type</TD>
|
||||
<TD VAlign="top"><code>range_reverse_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_reverse_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">The type of iterator used to iterate through a Range's elements
|
||||
in reverse order. The iterator's value type is expected to be the Range's value
|
||||
type. A conversion from the reverse iterator type to the const reverse iterator
|
||||
@ -352,7 +370,7 @@ s-lib-bidirectional-traversal-iterators">Bidirectional Traversal Iterator.</a>
|
||||
<TR>
|
||||
<TD VAlign="top">Const reverse iterator type</TD>
|
||||
<TD
|
||||
VAlign="top"><code>range_const_reverse_iterator<X>::type</code></TD>
|
||||
VAlign="top"><code>boost::range_const_reverse_iterator<X>::type</code></TD>
|
||||
<TD VAlign="top">A type of reverse iterator that may be used to examine, but not
|
||||
to modify, a Range's elements.</TD>
|
||||
</TR>
|
||||
@ -370,27 +388,27 @@ VAlign="top"><code>range_const_reverse_iterator<X>::type</code></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Beginning of range</TD>
|
||||
<TD VAlign="top"><code>rbegin(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_reverse_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_reverse_iterator<X>::type</code>
|
||||
<TD VAlign="top"><code>boost::rbegin(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_reverse_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>boost::range_const_reverse_iterator<X>::type</code>
|
||||
otherwise.</TD>
|
||||
<TD VAlign="top">Equivalent to
|
||||
<code>range_reverse_iterator<X>::type(end(a))</code>.</TD> </TR>
|
||||
<code>boost::range_reverse_iterator<X>::type(boost::end(a))</code>.</TD> </TR>
|
||||
<TR>
|
||||
<TD VAlign="top">End of range</TD>
|
||||
<TD VAlign="top"><code>rend(a)</code></TD>
|
||||
<TD VAlign="top"><code>range_reverse_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>range_const_reverse_iterator<X>::type</code>
|
||||
<TD VAlign="top"><code>boost::rend(a)</code></TD>
|
||||
<TD VAlign="top"><code>boost::range_reverse_iterator<X>::type</code> if
|
||||
<code>a</code> is mutable, <code>boost::range_const_reverse_iterator<X>::type</code>
|
||||
otherwise.</TD>
|
||||
<TD VAlign="top">Equivalent to
|
||||
<code>range_reverse_iterator<X>::type(begin(a))</code>.</TD> </tr>
|
||||
<code>boost::range_reverse_iterator<X>::type(boost::begin(a))</code>.</TD> </tr>
|
||||
|
||||
</table>
|
||||
|
||||
<h3>Complexity guarantees</h3>
|
||||
|
||||
<code>rbegin(a)</code> has the same complexity as <code>end(a)</code> and <code>rend(a)</code>
|
||||
has the same complexity as <code>begin(a)</code> from <a
|
||||
<code>boost::rbegin(a)</code> has the same complexity as <code>boost::end(a)</code> and <code>boost::rend(a)</code>
|
||||
has the same complexity as <code>boost::begin(a)</code> from <a
|
||||
href="#forward_range">Forward Range</a>.
|
||||
|
||||
<h3>Invariants</h3>
|
||||
@ -398,22 +416,29 @@ otherwise.</TD>
|
||||
<Table border="1" cellpadding="5">
|
||||
<TR>
|
||||
<TD VAlign="top">Valid reverse range</TD>
|
||||
<TD VAlign="top">For any Bidirectional Range <code>a</code>, <code>[rbegin(a),rend(a))</code>
|
||||
is a valid range, that is, <code>rend(a)</code> is reachable from <code>rbegin(a)</code>
|
||||
<TD VAlign="top">For any Bidirectional Range <code>a</code>, <code>[boost::rbegin(a),boost::rend(a))</code>
|
||||
is a valid range, that is, <code>boost::rend(a)</code> is reachable from <code>boost::rbegin(a)</code>
|
||||
in a finite number of increments.</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VAlign="top">Completeness</TD>
|
||||
<TD VAlign="top">An algorithm that iterates through the range <code>[rbegin(a),rend(a))</code>
|
||||
<TD VAlign="top">An algorithm that iterates through the range <code>[boost::rbegin(a),boost::rend(a))</code>
|
||||
will pass through every element of <code>a</code>.</TD>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<h3>See also</h3>
|
||||
<p> <a href="boost_range.html#boost::range_reverse_iterator">implementation of metafunctions </a></p>
|
||||
|
||||
<p> <a href="boost_range.html#rbegin">implementation of
|
||||
functions </a></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<a name=random_access_range><h2>Random Access Range</h2> <h3>Description</h3>
|
||||
<p>
|
||||
A range <code>X</code> where <code>range_iterator<X>::type</code> is a model
|
||||
A range <code>X</code> where <code>boost::range_iterator<X>::type</code> is a model
|
||||
of <a
|
||||
|
||||
href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterators
|
||||
@ -427,6 +452,59 @@ href="../../iterator/doc/new-iter-concepts.html#random-access-traversal-iterator
|
||||
|
||||
<hr>
|
||||
|
||||
<a name=concept_checking><h2>Concept Checking</h2>
|
||||
|
||||
Each of the range concepts has a corresponding concept checking
|
||||
class in the file boost/range/concepts.hpp. These classes may be
|
||||
used in conjunction with the <a
|
||||
href="../../concept_check/concept_check.htm">Boost Concept
|
||||
Check</a> library to insure that the type of a template parameter
|
||||
is compatible with a range concept. If not, a meaningful compile
|
||||
time error is generated. Checks are provided for the range
|
||||
concepts related to iterator traversal categories. For example,
|
||||
the following line checks that the type <code>T</code> models the
|
||||
<a href="#forward_range">ForwardRange</a> concept.
|
||||
|
||||
<pre>
|
||||
function_requires<ForwardRangeConcept<T> >();
|
||||
</pre>
|
||||
|
||||
An additional concept check is required for the value access
|
||||
property of the range based on the range's iterator type. For
|
||||
example to check for a ForwardReadableRange, the following code is
|
||||
required.
|
||||
|
||||
<pre>
|
||||
function_requires<ForwardRangeConcept<T> >();
|
||||
function_requires<
|
||||
ReadableIteratorConcept<
|
||||
typename range_iterator<T>::type
|
||||
>
|
||||
>();
|
||||
</pre>
|
||||
|
||||
The following range concept checking classes are provided.
|
||||
<ul>
|
||||
<li>
|
||||
Class <code>SinglePassRangeConcept</code> checks for <a
|
||||
href="#single_pass_range">Single Pass Range</a>
|
||||
<li>
|
||||
Class <code>ForwardRangeConcept</code> checks for <a
|
||||
href="#forward_range">Forward Range</a>
|
||||
<li>
|
||||
Class <code>BidirectionalRangeConcept</code> checks for <a
|
||||
href="#bidirectional_range">Bidirectional Range</a>
|
||||
<li>
|
||||
Class <code>RandomAccessRangeConcept</code> checks for <a
|
||||
href="#random_access_range">Random Access Range</a>
|
||||
</ul>
|
||||
|
||||
<h3>See also</h3>
|
||||
<p> <a href="style.html">Range Terminology and style guidelines</a></p>
|
||||
<p> <a href="../../iterator/doc/iterator_concepts.html">Iterator Concepts</a></p>
|
||||
<p> <a href="../../concept_check/concept_check.htm">Boost Concept Check library</a></p>
|
||||
|
||||
<hr>
|
||||
|
||||
<!--
|
||||
<h3>Notes</h3>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<h2>Terminology and style guidelines </h2>
|
||||
|
||||
<p>
|
||||
The use of a consistent terminology is as important for <a href="range.html#range">Range</a>s
|
||||
The use of a consistent terminology is as important for <a href="range.html">Range</a>s
|
||||
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 <i>self-documenting</i>.
|
||||
|
@ -111,14 +111,16 @@ corresponding <code>const_iterator</code> is. </p>
|
||||
</span><span class=keyword>bool </span><span class=identifier>empty</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
|
||||
|
||||
</span><span class=keyword>public</span><span class=special>: </span><span class=comment>// convenience
|
||||
</span><span class=keyword>operator </span><a
|
||||
href="#unspecified_bool"><span class=identifier>unspecified_bool_type</span></a><span class=special>() </span><span class=keyword>const</span><span class=special>;
|
||||
</span> <span class=keyword>bool</span> <span
|
||||
</span><span class=keyword>operator </span><a href="#unspecified_bool"><span class=identifier>unspecified_bool_type</span></a><span class=special>() </span><span class=keyword>const</span><span class=special>;
|
||||
</span> <span class=keyword>bool</span> <span
|
||||
class=identifier><a href="#equal">equal</a></span><span
|
||||
class=special>( </span><span class=keyword>const <span
|
||||
class=identifier>iterator_range</span><span class=special>& ) </span><span
|
||||
class=keyword>const;</span>
|
||||
|
||||
<span class=identifier>value_type</span><span class=special>& </span><span class=identifier>front</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=identifier>value_type</span><span class=special>& </span><span class=identifier>back</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=comment>// for Random Access Range only: </span>
|
||||
<span class=identifier>value_type</span><span class=special>& </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>size_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
|
||||
</span><span class=special>};
|
||||
|
||||
</span><span class=comment>// stream output
|
||||
@ -177,19 +179,25 @@ class=keyword>const;</span>
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>>
|
||||
</span><span class=identifier>iterator_range</span><span class=special>< </span><span class=keyword>typename </span><span class=identifier>const_iterator_of</span><span class=special><</span><span class=identifier>ForwardRange</span><span class=special>>::</span><span class=identifier>type </span><span class=special>>
|
||||
</span><span class=identifier>make_iterator_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
|
||||
</span>
|
||||
<span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>Range </span><span class=special>></span>
|
||||
<span class=identifier>iterator_range</span><span class=special>< </span><span class=keyword>typename </span><span class=identifier>range_iterator</span><span class=special><</span><span class=identifier>Range</span><span class=special>>::</span><span class=identifier>type </span><span class=special>></span>
|
||||
<span class=identifier><a href="#make_iterator_range">make_iterator_range</a></span><span class=special>(</span><span class=identifier> Range</span><span class=special>& </span><span class=identifier>r</span><span class=special>,
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special><</span><span class=identifier>Range</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>advance_begin</span><span class=special>,
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special><</span><span class=identifier>Range</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>advance_end </span><span class=special>);
|
||||
</span>
|
||||
<span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>Range </span><span class=special>></span>
|
||||
<span class=identifier>iterator_range</span><span class=special>< </span><span class=keyword>typename </span><span class=identifier>range_const_iterator</span><span class=special><</span><span class=identifier>Range</span><span class=special>>::</span><span class=identifier>type </span><span class=special>></span>
|
||||
<span class=identifier>make_iterator_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>Range</span><span class=special>& </span><span class=identifier>r</span><span class=special>,
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special><</span><span class=identifier>Range</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>advance_begin</span><span class=special>,
|
||||
</span><span class=keyword>typename </span><span class=identifier>range_difference</span><span class=special><</span><span class=identifier>Range</span><span class=special>>::</span><span class=identifier>type </span><span class=identifier>advance_end </span><span class=special>);</span>
|
||||
|
||||
</span><span class=comment>// convenience
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>Sequence</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange </span><span class=special>>
|
||||
</span><span class=identifier>Sequence </span><a href="#copy_range"><span
|
||||
class=identifier>copy_range</span></a><span class=special>( </span><span
|
||||
class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>Sequence</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>ForwardRange</span><span class=special>, </span><span class=keyword>class </span><span class=identifier>Func </span><span class=special>>
|
||||
</span><span class=identifier>Sequence </span><a
|
||||
href="#transform_range"><span
|
||||
class=identifier>transform_range</span></a><span class=special>( </span><span
|
||||
class=keyword>const </span><span class=identifier>ForwardRange</span><span class=special>& </span><span class=identifier>r</span><span class=special>, </span><span class=identifier>Func </span><span class=identifier>func </span><span class=special>);
|
||||
</span>
|
||||
</span>
|
||||
<span class=special>} </span><span class=comment>// namespace 'boost'</span>
|
||||
</pre>
|
||||
|
||||
@ -240,6 +248,24 @@ non-const iterators from the same container. </p>
|
||||
<code>bool operator<( const ForwardRange1& l, const ForwardRange2& r );</code>
|
||||
<blockquote>
|
||||
<i>Returns</i> <code>std::lexicographical_compare( begin(l), end(l), begin(r), end(r) );</code> </blockquote>
|
||||
|
||||
<p>
|
||||
<a name="make_iterator_range"></a>
|
||||
<pre>
|
||||
iterator_range make_iterator_range( Range& r,
|
||||
typename range_difference<Range>::type advance_begin,
|
||||
typename range_difference<Range>::type advance_end );
|
||||
</pre>
|
||||
<blockquote>
|
||||
<i>Effects</i>:
|
||||
<pre>
|
||||
iterator new_begin = begin( r ),
|
||||
iterator new_end = end( r );
|
||||
std::advance( new_begin, advance_begin );
|
||||
std::advance( new_end, advance_end );
|
||||
return make_iterator_range( new_begin, new_end );
|
||||
</pre>
|
||||
</blockquote>
|
||||
<p>
|
||||
<a name="copy_range"></a>
|
||||
<code>Sequence copy_range( const ForwardRange& r );</code>
|
||||
@ -248,18 +274,6 @@ non-const iterators from the same container. </p>
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a name="transform_range"></a>
|
||||
<code>Sequence transform_range( const ForwardRange& r, Func func );</code>
|
||||
<blockquote>
|
||||
<i>Effects</i> <br>
|
||||
<code>Sequence seq;</code> <br>
|
||||
<code>std::transform( begin(r), end(r), std::back_inserter(seq), func );</code>
|
||||
<br>
|
||||
<code>return seq;</code>
|
||||
</blockquote>
|
||||
</p>
|
||||
|
||||
<hr> <a name=sub_range></a>
|
||||
<h1>Class <code>sub_range</code></h1>
|
||||
|
||||
@ -299,15 +313,23 @@ class can propagate constness since it knows what a corresponding
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardRange2 </span><span class=special>>
|
||||
</span><span class=identifier>sub_range</span><span class=special>& </span><span class=keyword>operator</span><span class=special>=( </span><span class=keyword>const </span><span class=identifier>ForwardRange2</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
</span>
|
||||
<span class=keyword>public</span><span class=special>:
|
||||
</span><span class=identifier>iterator </span><span
|
||||
class=identifier>begin</span><span class=special>();
|
||||
<span class=keyword>public</span><span class=special>: </span><span class=comment>// Forward Range functions
|
||||
</span><span class=identifier>iterator </span><span class=identifier>begin</span><span class=special>();
|
||||
</span><span class=identifier>const_iterator </span><span class=identifier>begin</span><span class=special>() </span><span class=keyword>const</span><span class=special>;
|
||||
</span><span class=identifier>iterator </span><span class=identifier>end</span><span class=special>();
|
||||
</span><span class=identifier>const_iterator </span><span class=identifier>end</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>: </span><span class=comment>// convenience
|
||||
</span> <span class=identifier>value_type</span><span class=special>& </span><span class=identifier>front</span><span class=special>();</span>
|
||||
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>& </span><span class=identifier>front</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=identifier>value_type</span><span class=special>& </span><span class=identifier>back</span><span class=special>();</span>
|
||||
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>& </span><span class=identifier>back</span><span class=special>() </span><span class=keyword>const</span><span class=special>;</span>
|
||||
<span class=comment>// for Random Access Range only: </span>
|
||||
<span class=identifier>value_type</span><span class=special>& </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>size_type </span><span class=identifier>at </span><span class=special>);</span>
|
||||
<span class=keyword>const </span><span class=identifier>value_type</span><span class=special>& </span><span class=keyword>operator</span><span class=special>[]( </span><span class=identifier>size_type </span><span class=identifier>at </span><span class=special>) </span><span class=keyword>const</span><span class=special>;</span>
|
||||
|
||||
<span class=keyword>public</span><span class=special>:
|
||||
</span><span class=comment>// rest of interface inherited from iterator_range
|
||||
</span><span class=comment>// rest of interface inherited from <a href=#iter_range><code>iterator_range</code></a>
|
||||
</span><span class=special>};
|
||||
</span>
|
||||
<span class=special>} </span><span class=comment>// namespace 'boost'</span>
|
||||
|
@ -15,9 +15,19 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if _MSC_VER == 1300 // experiment
|
||||
|
||||
#include <boost/range/detail/collection_traits.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/sub_range.hpp>
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/sub_range.hpp>
|
||||
|
||||
#endif // _MSC_VER == 1300 // experiment
|
||||
|
||||
#endif
|
||||
|
45
include/boost/range/as_array.hpp
Executable file
45
include/boost/range/as_array.hpp
Executable file
@ -0,0 +1,45 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_AS_ARRAY_HPP
|
||||
#define BOOST_RANGE_AS_ARRAY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/detail/str_types.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class R >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<R>::type >
|
||||
as_array( R& r )
|
||||
{
|
||||
return boost::make_iterator_range( r );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class Range >
|
||||
inline boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
|
||||
as_array( const Range& r )
|
||||
{
|
||||
return boost::make_iterator_range( r );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
120
include/boost/range/as_literal.hpp
Executable file
120
include/boost/range/as_literal.hpp
Executable file
@ -0,0 +1,120 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_AS_LITERAL_HPP
|
||||
#define BOOST_RANGE_DETAIL_AS_LITERAL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#include <boost/range/detail/as_literal.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/detail/str_types.hpp>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
inline std::size_t length( const char* s )
|
||||
{
|
||||
return strlen( s );
|
||||
}
|
||||
|
||||
inline std::size_t length( const wchar_t* s )
|
||||
{
|
||||
return wcslen( s );
|
||||
}
|
||||
|
||||
//
|
||||
// Remark: the compiler cannot choose between T* and T[sz]
|
||||
// overloads, so we must put the T* internal to the
|
||||
// unconstrained version.
|
||||
//
|
||||
|
||||
inline bool is_char_ptr( char* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_char_ptr( const char* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
inline bool is_char_ptr( wchar_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool is_char_ptr( const wchar_t* )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline long is_char_ptr( T r )
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline iterator_range<T*>
|
||||
make_range( T* const r, bool )
|
||||
{
|
||||
return iterator_range<T*>( r, r + length(r) );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<T>::type>
|
||||
make_range( T& r, long )
|
||||
{
|
||||
return boost::make_iterator_range( r );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
|
||||
as_literal( Range& r )
|
||||
{
|
||||
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
|
||||
}
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type>
|
||||
as_literal( const Range& r )
|
||||
{
|
||||
return range_detail::make_range( r, range_detail::is_char_ptr(r) );
|
||||
}
|
||||
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
|
||||
{
|
||||
return boost::make_iterator_range( arr, arr + sz - 1 );
|
||||
}
|
||||
|
||||
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
|
||||
{
|
||||
return boost::make_iterator_range( arr, arr + sz - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
#endif
|
@ -22,154 +22,106 @@
|
||||
#else
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// primary template
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
|
||||
begin( const C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
begin( C& c )
|
||||
range_begin( C& c )
|
||||
{
|
||||
return c.begin();
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator begin( const std::pair<Iterator,Iterator>& p )
|
||||
inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator begin( std::pair<Iterator,Iterator>& p )
|
||||
inline Iterator range_begin( std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// May this be discarded? Or is it needed for bad compilers?
|
||||
//
|
||||
template< typename T, std::size_t sz >
|
||||
inline const T* begin( const T (&array)[sz] )
|
||||
inline const T* range_begin( const T (&array)[sz] )
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline T* begin( T (&array)[sz] )
|
||||
inline T* range_begin( T (&array)[sz] )
|
||||
{
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// CW up to 9.3 and borland have troubles with function ordering
|
||||
inline const char* begin( const char* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
inline char* begin( char* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
inline const wchar_t* begin( const wchar_t* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
inline wchar_t* begin( wchar_t* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
#else
|
||||
inline const char* begin( const char*& s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
inline char* begin( char*& s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
inline const wchar_t* begin( const wchar_t*& s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
inline wchar_t* begin( wchar_t*& s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
} // namespace 'range_detail'
|
||||
#endif
|
||||
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
|
||||
{
|
||||
return range_detail::begin( r );
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_begin( r );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type begin( const T& r )
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
|
||||
{
|
||||
return range_detail::begin( r );
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// BCB and CW are not able to overload pointer when class overloads are also available.
|
||||
template<>
|
||||
inline range_const_iterator<const char*>::type begin<const char*>( const char*& r )
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline range_const_iterator<const wchar_t*>::type begin<const wchar_t*>( const wchar_t*& r )
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_begin( r );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
|
||||
const_begin( const T& r )
|
||||
{
|
||||
return begin( r );
|
||||
return boost::begin( r );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
29
include/boost/range/category.hpp
Executable file
29
include/boost/range/category.hpp
Executable file
@ -0,0 +1,29 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_CATEGORY_HPP
|
||||
#define BOOST_RANGE_CATEGORY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_category : iterator_category< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
155
include/boost/range/concepts.hpp
Executable file
155
include/boost/range/concepts.hpp
Executable file
@ -0,0 +1,155 @@
|
||||
// Boost.Range library concept checks
|
||||
//
|
||||
// Copyright Daniel Walker 2006. Use, modification and distribution
|
||||
// are subject to the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_CONCEPTS_HPP
|
||||
#define BOOST_RANGE_CONCEPTS_HPP
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/iterator/iterator_concepts.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \brief Concept checks for the Boost Range library.
|
||||
*
|
||||
* The structures in this file may be used in conjunction with the
|
||||
* Boost Concept Check library to insure that the type of a function
|
||||
* parameter is compatible with a range concept. If not, a meaningful
|
||||
* compile time error is generated. Checks are provided for the range
|
||||
* concepts related to iterator traversal categories. For example, the
|
||||
* following line checks that the type T models the ForwardRange
|
||||
* concept.
|
||||
*
|
||||
* \code
|
||||
* function_requires<ForwardRangeConcept<T> >();
|
||||
* \endcode
|
||||
*
|
||||
* An additional concept check is required for the value access
|
||||
* property of the range. For example to check for a
|
||||
* ForwardReadableRange, the following code is required.
|
||||
*
|
||||
* \code
|
||||
* function_requires<ForwardRangeConcept<T> >();
|
||||
* function_requires<
|
||||
* ReadableIteratorConcept<
|
||||
* typename range_iterator<T>::type
|
||||
* >
|
||||
* >();
|
||||
* \endcode
|
||||
*
|
||||
* \see http://www.boost.org/libs/range/doc/range.html for details
|
||||
* about range concepts.
|
||||
* \see http://www.boost.org/libs/iterator/doc/iterator_concepts.html
|
||||
* for details about iterator concepts.
|
||||
* \see http://www.boost.org/libs/concept_check/concept_check.htm for
|
||||
* details about concept checks.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
|
||||
//! Check if a type T models the SinglePassRange range concept.
|
||||
template<typename T>
|
||||
struct SinglePassRangeConcept {
|
||||
typedef typename range_value<T>::type range_value;
|
||||
typedef typename range_iterator<T>::type range_iterator;
|
||||
typedef typename range_const_iterator<T>::type range_const_iterator;
|
||||
void constraints()
|
||||
{
|
||||
function_requires<
|
||||
boost_concepts::SinglePassIteratorConcept<
|
||||
range_iterator
|
||||
>
|
||||
>();
|
||||
i = boost::begin(a);
|
||||
i = boost::end(a);
|
||||
b = boost::empty(a);
|
||||
const_constraints(a);
|
||||
}
|
||||
void const_constraints(const T& a)
|
||||
{
|
||||
ci = boost::begin(a);
|
||||
ci = boost::end(a);
|
||||
}
|
||||
T a;
|
||||
range_iterator i;
|
||||
range_const_iterator ci;
|
||||
bool b;
|
||||
};
|
||||
|
||||
//! Check if a type T models the ForwardRange range concept.
|
||||
template<typename T>
|
||||
struct ForwardRangeConcept {
|
||||
typedef typename range_difference<T>::type range_difference;
|
||||
typedef typename range_size<T>::type range_size;
|
||||
void constraints()
|
||||
{
|
||||
function_requires<
|
||||
SinglePassRangeConcept<T>
|
||||
>();
|
||||
function_requires<
|
||||
boost_concepts::ForwardTraversalConcept<
|
||||
typename range_iterator<T>::type
|
||||
>
|
||||
>();
|
||||
s = boost::size(a);
|
||||
}
|
||||
T a;
|
||||
range_size s;
|
||||
};
|
||||
|
||||
//! Check if a type T models the BidirectionalRange range concept.
|
||||
template<typename T>
|
||||
struct BidirectionalRangeConcept {
|
||||
typedef typename range_reverse_iterator<T>::type range_reverse_iterator;
|
||||
typedef typename range_const_reverse_iterator<T>::type range_const_reverse_iterator;
|
||||
void constraints()
|
||||
{
|
||||
function_requires<
|
||||
ForwardRangeConcept<T>
|
||||
>();
|
||||
function_requires<
|
||||
boost_concepts::BidirectionalTraversalConcept<
|
||||
typename range_iterator<T>::type
|
||||
>
|
||||
>();
|
||||
i = boost::rbegin(a);
|
||||
i = boost::rend(a);
|
||||
const_constraints(a);
|
||||
}
|
||||
void const_constraints(const T& a)
|
||||
{
|
||||
ci = boost::rbegin(a);
|
||||
ci = boost::rend(a);
|
||||
}
|
||||
T a;
|
||||
range_reverse_iterator i;
|
||||
range_const_reverse_iterator ci;
|
||||
};
|
||||
|
||||
//! Check if a type T models the RandomAccessRange range concept.
|
||||
template<typename T>
|
||||
struct RandomAccessRangeConcept {
|
||||
void constraints()
|
||||
{
|
||||
function_requires<
|
||||
BidirectionalRangeConcept<T>
|
||||
>();
|
||||
function_requires<
|
||||
boost_concepts::RandomAccessTraversalConcept<
|
||||
typename range_iterator<T>::type
|
||||
>
|
||||
>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_RANGE_CONCEPTS_HPP
|
@ -24,24 +24,29 @@
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
#define BOOST_RANGE_DEDUCED_TYPENAME
|
||||
# define BOOST_RANGE_DEDUCED_TYPENAME typename
|
||||
#else
|
||||
#define BOOST_RANGE_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) && !defined(_MSC_EXTENSIONS)
|
||||
# define BOOST_RANGE_DEDUCED_TYPENAME typename
|
||||
# else
|
||||
# define BOOST_RANGE_DEDUCED_TYPENAME BOOST_DEDUCED_TYPENAME
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
|
||||
#error "macro already defined!"
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1200 && !defined( __COMO__ ) && !defined( __GNUC__ ) && __MWERKS__ <= 0x3003
|
||||
//#if BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) || __MWERKS__ <= 0x3003
|
||||
#if _MSC_VER <= 1300 && !defined( __COMO__ ) && !defined( __GNUC__ ) && __MWERKS__ <= 0x3003
|
||||
#define BOOST_RANGE_NO_ARRAY_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_RANGE_NO_ARRAY_SUPPORT
|
||||
#define BOOST_RANGE_ARRAY_REF() (array)
|
||||
#define BOOST_RANGE_ARRAY_REF() (boost_range_array)
|
||||
#define BOOST_RANGE_NO_STATIC_ASSERT
|
||||
#else
|
||||
#define BOOST_RANGE_ARRAY_REF() (&array)
|
||||
#define BOOST_RANGE_ARRAY_REF() (&boost_range_array)
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <boost/range/detail/const_iterator.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
@ -46,12 +47,6 @@ namespace boost
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_const_iterator< const std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -62,40 +57,6 @@ namespace boost
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_const_iterator< const T[sz] >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_const_iterator< char* >
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator< wchar_t* >
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator< const char* >
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator< const wchar_t* >
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
@ -15,22 +15,17 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This interface is deprecated, use range_reverse_iterator<const T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_const_reverse_iterator
|
||||
{
|
||||
typedef reverse_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type > type;
|
||||
};
|
||||
struct range_const_reverse_iterator : range_reverse_iterator<const C>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
33
include/boost/range/detail/as_literal.hpp
Executable file
33
include/boost/range/detail/as_literal.hpp
Executable file
@ -0,0 +1,33 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_AS_LITERAL_HPP
|
||||
#define BOOST_RANGE_AS_LITERAL_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/detail/detail_str.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class Range >
|
||||
inline iterator_range<BOOST_DEDUCED_TYPENAME range_iterator<Range>::type>
|
||||
as_literal( Range& r )
|
||||
{
|
||||
return ::boost::make_iterator_range( ::boost::range_detail::str_begin(r),
|
||||
::boost::range_detail::str_end(r) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -11,8 +11,13 @@
|
||||
#ifndef BOOST_RANGE_DETAIL_BEGIN_HPP
|
||||
#define BOOST_RANGE_DETAIL_BEGIN_HPP
|
||||
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
|
||||
# include <boost/range/value_type.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -30,7 +35,7 @@ namespace boost
|
||||
struct range_begin<std_container_>
|
||||
{
|
||||
template< typename C >
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type fun( C& c )
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
|
||||
{
|
||||
return c.begin();
|
||||
};
|
||||
@ -44,7 +49,7 @@ namespace boost
|
||||
struct range_begin<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type fun( const P& p )
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
@ -57,61 +62,28 @@ namespace boost
|
||||
template<>
|
||||
struct range_begin<array_>
|
||||
{
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
|
||||
template< typename T, std::size_t sz >
|
||||
static T* fun( T BOOST_ARRAY_REF[sz] )
|
||||
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return array;
|
||||
return boost_range_array;
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_begin<char_ptr_>
|
||||
{
|
||||
static char* fun( char* s )
|
||||
#else
|
||||
template<typename T>
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_begin<const_char_ptr_>
|
||||
{
|
||||
static const char* fun( const char* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_begin<wchar_t_ptr_>
|
||||
{
|
||||
|
||||
static wchar_t* fun( wchar_t* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_begin<const_wchar_t_ptr_>
|
||||
{
|
||||
static const wchar_t* fun( const wchar_t* s )
|
||||
{
|
||||
return s;
|
||||
return t;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
|
||||
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
begin( C& c )
|
||||
{
|
||||
return range_detail::range_begin< BOOST_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
|
||||
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
266
include/boost/range/detail/collection_traits.hpp
Executable file
266
include/boost/range/detail/collection_traits.hpp
Executable file
@ -0,0 +1,266 @@
|
||||
// Boost string_algo library collection_traits.hpp header file -------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// (C) Copyright Thorsten Ottosen 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// (C) Copyright Jeremy Siek 2001. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Original idea of container traits was proposed by Jeremy Siek and
|
||||
// Thorsten Ottosen. This implementation is lightweighted version
|
||||
// of container_traits adapter for usage with string_algo library
|
||||
|
||||
#ifndef BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
|
||||
#define BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
|
||||
// Implementation
|
||||
#include <boost/range/detail/collection_traits_detail.hpp>
|
||||
|
||||
/*! \file
|
||||
Defines collection_traits class and related free-standing functions.
|
||||
This facility is used to unify the access to different types of collections.
|
||||
It allows the algorithms in the library to work with STL collections, c-style
|
||||
array, null-terminated c-strings (and more) using the same interface.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
|
||||
// collection_traits template class -----------------------------------------//
|
||||
|
||||
//! collection_traits class
|
||||
/*!
|
||||
Collection traits provide uniform access to different types of
|
||||
collections. This functionality allows to write generic algorithms
|
||||
which work with several different kinds of collections.
|
||||
|
||||
Currently following collection types are supported:
|
||||
- containers with STL compatible container interface ( see ContainerConcept )
|
||||
( i.e. \c std::vector<>, \c std::list<>, \c std::string<> ... )
|
||||
- c-style array
|
||||
( \c char[10], \c int[15] ... )
|
||||
- null-terminated c-strings
|
||||
( \c char*, \c wchar_T* )
|
||||
- std::pair of iterators
|
||||
( i.e \c std::pair<vector<int>::iterator,vector<int>::iterator> )
|
||||
|
||||
Collection traits provide an external collection interface operations.
|
||||
All are accessible using free-standing functions.
|
||||
|
||||
The following operations are supported:
|
||||
- \c size()
|
||||
- \c empty()
|
||||
- \c begin()
|
||||
- \c end()
|
||||
|
||||
Container traits have somewhat limited functionality on compilers not
|
||||
supporting partial template specialization and partial template ordering.
|
||||
*/
|
||||
template< typename T >
|
||||
struct collection_traits
|
||||
{
|
||||
private:
|
||||
typedef BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
|
||||
::boost::algorithm::detail::is_pair<T>,
|
||||
detail::pair_container_traits_selector<T>,
|
||||
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
|
||||
::boost::is_array<T>,
|
||||
detail::array_container_traits_selector<T>,
|
||||
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
|
||||
::boost::is_pointer<T>,
|
||||
detail::pointer_container_traits_selector<T>,
|
||||
detail::default_container_traits_selector<T>
|
||||
>
|
||||
>
|
||||
>::type container_helper_type;
|
||||
public:
|
||||
//! Function type
|
||||
typedef container_helper_type function_type;
|
||||
//! Value type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::value_type value_type;
|
||||
//! Size type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::size_type size_type;
|
||||
//! Iterator type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::iterator iterator;
|
||||
//! Const iterator type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::const_iterator const_iterator;
|
||||
//! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::result_iterator result_iterator;
|
||||
//! Difference type
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
container_helper_type::difference_type difference_type;
|
||||
|
||||
}; // 'collection_traits'
|
||||
|
||||
// collection_traits metafunctions -----------------------------------------//
|
||||
|
||||
//! Container value_type trait
|
||||
/*!
|
||||
Extract the type of elements contained in a container
|
||||
*/
|
||||
template< typename C >
|
||||
struct value_type_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::value_type type;
|
||||
};
|
||||
|
||||
//! Container difference trait
|
||||
/*!
|
||||
Extract the container's difference type
|
||||
*/
|
||||
template< typename C >
|
||||
struct difference_type_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::difference_type type;
|
||||
};
|
||||
|
||||
//! Container iterator trait
|
||||
/*!
|
||||
Extract the container's iterator type
|
||||
*/
|
||||
template< typename C >
|
||||
struct iterator_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::iterator type;
|
||||
};
|
||||
|
||||
//! Container const_iterator trait
|
||||
/*!
|
||||
Extract the container's const_iterator type
|
||||
*/
|
||||
template< typename C >
|
||||
struct const_iterator_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::const_iterator type;
|
||||
};
|
||||
|
||||
|
||||
//! Container result_iterator
|
||||
/*!
|
||||
Extract the container's result_iterator type. This type maps to \c C::iterator
|
||||
for mutable container and \c C::const_iterator for const containers.
|
||||
*/
|
||||
template< typename C >
|
||||
struct result_iterator_of
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME collection_traits<C>::result_iterator type;
|
||||
};
|
||||
|
||||
// collection_traits related functions -----------------------------------------//
|
||||
|
||||
//! Free-standing size() function
|
||||
/*!
|
||||
Get the size of the container. Uses collection_traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::size_type
|
||||
size( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::size( c );
|
||||
}
|
||||
|
||||
//! Free-standing empty() function
|
||||
/*!
|
||||
Check whether the container is empty. Uses container traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline bool empty( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::empty( c );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! Free-standing begin() function
|
||||
/*!
|
||||
Get the begin iterator of the container. Uses collection_traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
|
||||
begin( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::begin( c );
|
||||
}
|
||||
|
||||
//! Free-standing begin() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
|
||||
begin( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::begin( c );
|
||||
}
|
||||
|
||||
//! Free-standing end() function
|
||||
/*!
|
||||
Get the begin iterator of the container. Uses collection_traits.
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
|
||||
end( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::end( c );
|
||||
}
|
||||
|
||||
//! Free-standing end() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
|
||||
end( const C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::end( c );
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
//! Free-standing begin() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
|
||||
begin( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::begin( c );
|
||||
}
|
||||
|
||||
//! Free-standing end() function
|
||||
/*!
|
||||
\overload
|
||||
*/
|
||||
template< typename C >
|
||||
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
|
||||
end( C& c )
|
||||
{
|
||||
return collection_traits<C>::function_type::end( c );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_STRING_COLLECTION_TRAITS_HPP
|
621
include/boost/range/detail/collection_traits_detail.hpp
Executable file
621
include/boost/range/detail/collection_traits_detail.hpp
Executable file
@ -0,0 +1,621 @@
|
||||
// Boost string_algo library collection_traits.hpp header file -----------------------//
|
||||
|
||||
// Copyright Pavol Droba 2002-2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
|
||||
#define BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
|
||||
|
||||
#include <boost/algorithm/string/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/vector.hpp>
|
||||
#include <boost/mpl/fold.hpp>
|
||||
#include <boost/detail/iterator.hpp>
|
||||
#include <boost/algorithm/string/yes_no_type.hpp>
|
||||
|
||||
// Container traits implementation ---------------------------------------------------------
|
||||
|
||||
namespace boost {
|
||||
namespace algorithm {
|
||||
namespace detail {
|
||||
|
||||
// Default collection traits -----------------------------------------------------------------
|
||||
|
||||
// Default collection helper
|
||||
/*
|
||||
Wraps std::container compliant containers
|
||||
*/
|
||||
template< typename ContainerT >
|
||||
struct default_container_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::if_< ::boost::is_const<ContainerT>,
|
||||
const_iterator,
|
||||
iterator
|
||||
>::type result_iterator;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type;
|
||||
typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type;
|
||||
|
||||
// static operations
|
||||
template< typename C >
|
||||
static size_type size( const C& c )
|
||||
{
|
||||
return c.size();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static bool empty( const C& c )
|
||||
{
|
||||
return c.empty();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename C >
|
||||
static iterator begin( C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static const_iterator begin( const C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static iterator end( C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static const_iterator end( const C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename C >
|
||||
static result_iterator begin( C& c )
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
static result_iterator end( C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct default_container_traits_selector
|
||||
{
|
||||
typedef default_container_traits<T> type;
|
||||
};
|
||||
|
||||
// Pair container traits ---------------------------------------------------------------------
|
||||
|
||||
// pair selector
|
||||
template< typename T, typename U >
|
||||
yes_type is_pair_impl( const std::pair<T,U>* );
|
||||
no_type is_pair_impl( ... );
|
||||
|
||||
template<typename T> struct is_pair
|
||||
{
|
||||
private:
|
||||
static T* t;
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( bool, value=
|
||||
sizeof(is_pair_impl(t))==sizeof(yes_type) );
|
||||
};
|
||||
|
||||
// pair helper
|
||||
template< typename PairT >
|
||||
struct pair_container_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME PairT::first_type element_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME ::boost::detail::
|
||||
iterator_traits<element_type>::value_type value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef BOOST_STRING_TYPENAME ::boost::detail::
|
||||
iterator_traits<element_type>::difference_type difference_type;
|
||||
|
||||
typedef element_type iterator;
|
||||
typedef element_type const_iterator;
|
||||
typedef element_type result_iterator;
|
||||
|
||||
// static operations
|
||||
template< typename P >
|
||||
static size_type size( const P& p )
|
||||
{
|
||||
difference_type diff = std::distance( p.first, p.second );
|
||||
if ( diff < 0 )
|
||||
return 0;
|
||||
else
|
||||
return diff;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static bool empty( const P& p )
|
||||
{
|
||||
return p.first==p.second;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator begin( const P& p )
|
||||
{
|
||||
return p.first;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator end( const P& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
}; // 'pair_container_helper'
|
||||
|
||||
template<typename T>
|
||||
struct pair_container_traits_selector
|
||||
{
|
||||
typedef pair_container_traits<T> type;
|
||||
};
|
||||
|
||||
// Array container traits ---------------------------------------------------------------
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
// array traits ( partial specialization )
|
||||
template< typename T >
|
||||
struct array_traits;
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct array_traits<T[sz]>
|
||||
{
|
||||
// typedef
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef T value_type;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// size of the array ( static );
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = sz );
|
||||
};
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// array traits ( no partial specialization )
|
||||
/*
|
||||
without parial specialization we are able to
|
||||
provide support only for a limited number of
|
||||
types. Currently the primitive numeric types
|
||||
are supported
|
||||
*/
|
||||
template< typename T, typename BaseT >
|
||||
struct array_traits_impl
|
||||
{
|
||||
typedef BaseT value_type;
|
||||
typedef BaseT* iterator;
|
||||
typedef const BaseT* const_iterator;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
// size of the array
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = sizeof(T)/sizeof(BaseT) );
|
||||
};
|
||||
|
||||
template< typename T, typename BaseT >
|
||||
struct array_traits_impl_selector
|
||||
{
|
||||
typedef array_traits_impl<T,BaseT> type;
|
||||
};
|
||||
|
||||
struct array_traits_void
|
||||
{
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
template< typename T, typename BaseT >
|
||||
struct array_traits_cv_selector
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::eval_if<
|
||||
::boost::is_convertible<T,BaseT*>,
|
||||
array_traits_impl_selector<T,BaseT>,
|
||||
::boost::mpl::eval_if<
|
||||
::boost::is_convertible<T,const BaseT*>,
|
||||
array_traits_impl_selector<T, const BaseT>,
|
||||
::boost::mpl::eval_if<
|
||||
::boost::is_convertible<T, volatile BaseT*>,
|
||||
array_traits_impl_selector<T, volatile BaseT>,
|
||||
array_traits_impl_selector<T, const volatile BaseT>
|
||||
>
|
||||
>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_traits_select
|
||||
{
|
||||
template< typename T1, typename T2 >
|
||||
struct apply
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::eval_if<
|
||||
::boost::is_convertible<T,const volatile T2*>,
|
||||
array_traits_cv_selector<T,T2>,
|
||||
::boost::mpl::identity<T1> >::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_traits_selector
|
||||
{
|
||||
private:
|
||||
// supported array base types
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::vector10<
|
||||
wchar_t,
|
||||
#else // BOOST_NO_INTRINSIC_WCHAR_T
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::vector9<
|
||||
#endif // BOOST_NO_INTRINSIC_WCHAR_T
|
||||
char,
|
||||
signed char,
|
||||
unsigned char,
|
||||
signed short,
|
||||
unsigned short,
|
||||
signed int,
|
||||
unsigned int,
|
||||
signed long,
|
||||
unsigned long
|
||||
>::type array_base_types;
|
||||
|
||||
public:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::fold<
|
||||
array_base_types,
|
||||
::boost::algorithm::detail::array_traits_void,
|
||||
::boost::algorithm::detail::array_traits_select<T> >::type type;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
array_traits_selector<T>::type traits_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::iterator iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::size_type size_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::difference_type difference_type;
|
||||
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// array lenght resolving
|
||||
/*
|
||||
Lenght of string contained in a static array could
|
||||
be different from the size of the array.
|
||||
For string processing we need the lenght without
|
||||
terminating 0.
|
||||
|
||||
Therefore, the lenght is calulated for char and wchar_t
|
||||
using char_traits, rather then simply returning
|
||||
the array size.
|
||||
*/
|
||||
template< typename T >
|
||||
struct array_length_selector
|
||||
{
|
||||
template< typename TraitsT >
|
||||
struct array_length
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
TraitsT::size_type size_type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
size_type,
|
||||
array_size=TraitsT::array_size );
|
||||
|
||||
template< typename A >
|
||||
static size_type length( const A& )
|
||||
{
|
||||
return array_size;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& )
|
||||
{
|
||||
return array_size==0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// specialization for char
|
||||
template<>
|
||||
struct array_length_selector<char>
|
||||
{
|
||||
template< typename TraitsT >
|
||||
struct array_length
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
TraitsT::size_type size_type;
|
||||
|
||||
template< typename A >
|
||||
static size_type length( const A& a )
|
||||
{
|
||||
if ( a==0 )
|
||||
return 0;
|
||||
else
|
||||
return std::char_traits<char>::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& a )
|
||||
{
|
||||
return a==0 || a[0]==0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// specialization for wchar_t
|
||||
template<>
|
||||
struct array_length_selector<wchar_t>
|
||||
{
|
||||
template< typename TraitsT >
|
||||
struct array_length
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
TraitsT::size_type size_type;
|
||||
|
||||
template< typename A >
|
||||
static size_type length( const A& a )
|
||||
{
|
||||
if ( a==0 )
|
||||
return 0;
|
||||
else
|
||||
return std::char_traits<wchar_t>::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& a )
|
||||
{
|
||||
return a==0 || a[0]==0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
struct array_container_traits
|
||||
{
|
||||
private:
|
||||
// resolve array traits
|
||||
typedef array_traits<T> traits_type;
|
||||
|
||||
public:
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::value_type value_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::iterator iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::const_iterator const_iterator;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::size_type size_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
traits_type::difference_type difference_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::if_< ::boost::is_const<T>,
|
||||
const_iterator,
|
||||
iterator
|
||||
>::type result_iterator;
|
||||
|
||||
private:
|
||||
// resolve array size
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::remove_cv<value_type>::type char_type;
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
array_length_selector<char_type>::
|
||||
BOOST_NESTED_TEMPLATE array_length<traits_type> array_length_type;
|
||||
|
||||
public:
|
||||
BOOST_STATIC_CONSTANT( size_type, array_size = traits_type::array_size );
|
||||
|
||||
// static operations
|
||||
template< typename A >
|
||||
static size_type size( const A& a )
|
||||
{
|
||||
return array_length_type::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static bool empty( const A& a )
|
||||
{
|
||||
return array_length_type::empty(a);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename A >
|
||||
static iterator begin( A& a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static const_iterator begin( const A& a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static iterator end( A& a )
|
||||
{
|
||||
return a+array_length_type::length(a);
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static const_iterator end( const A& a )
|
||||
{
|
||||
return a+array_length_type::length(a);
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename A >
|
||||
static result_iterator begin( A& a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
template< typename A >
|
||||
static result_iterator end( A& a )
|
||||
{
|
||||
return a+array_length_type::length(a);
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct array_container_traits_selector
|
||||
{
|
||||
typedef array_container_traits<T> type;
|
||||
};
|
||||
|
||||
// Pointer container traits ---------------------------------------------------------------
|
||||
|
||||
template<typename T>
|
||||
struct pointer_container_traits
|
||||
{
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::remove_pointer<T>::type value_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::remove_cv<value_type>::type char_type;
|
||||
typedef ::std::char_traits<char_type> char_traits;
|
||||
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::size_t size_type;
|
||||
|
||||
typedef BOOST_STRING_TYPENAME
|
||||
::boost::mpl::if_< ::boost::is_const<T>,
|
||||
const_iterator,
|
||||
iterator
|
||||
>::type result_iterator;
|
||||
|
||||
// static operations
|
||||
template< typename P >
|
||||
static size_type size( const P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return 0;
|
||||
else
|
||||
return char_traits::length(p);
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static bool empty( const P& p )
|
||||
{
|
||||
return p==0 || p[0]==0;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename P >
|
||||
static iterator begin( P& p )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator begin( const P& p )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static iterator end( P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return p;
|
||||
else
|
||||
return p+char_traits::length(p);
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static const_iterator end( const P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return p;
|
||||
else
|
||||
return p+char_traits::length(p);
|
||||
}
|
||||
|
||||
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename P >
|
||||
static result_iterator begin( P& p )
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template< typename P >
|
||||
static result_iterator end( P& p )
|
||||
{
|
||||
if ( p==0 )
|
||||
return p;
|
||||
else
|
||||
return p+char_traits::length(p);
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct pointer_container_traits_selector
|
||||
{
|
||||
typedef pointer_container_traits<T> type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace algorithm
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_STRING_DETAIL_COLLECTION_HPP
|
@ -78,35 +78,35 @@ namespace boost
|
||||
template< typename C >
|
||||
class range
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_pair_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_pair_,
|
||||
boost::range_detail::std_pair_,
|
||||
void >::type pair_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_array_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_array_,
|
||||
boost::range_detail::array_,
|
||||
pair_t >::type array_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_string_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_string_,
|
||||
boost::range_detail::string_,
|
||||
array_t >::type string_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_const_char_ptr_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_char_ptr_,
|
||||
boost::range_detail::const_char_ptr_,
|
||||
string_t >::type const_char_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_char_ptr_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_ptr_,
|
||||
boost::range_detail::char_ptr_,
|
||||
const_char_ptr_t >::type char_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
|
||||
boost::range_detail::const_wchar_t_ptr_,
|
||||
char_ptr_t >::type const_wchar_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_ptr_,
|
||||
boost::range_detail::wchar_t_ptr_,
|
||||
const_wchar_ptr_t >::type wchar_ptr_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_wchar_t_array_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_wchar_t_array_,
|
||||
boost::range_detail::wchar_t_array_,
|
||||
wchar_ptr_t >::type wchar_array_t;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::range_helper<C>::is_char_array_,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::range_detail::range_helper<C>::is_char_array_,
|
||||
boost::range_detail::char_array_,
|
||||
wchar_array_t >::type char_array_t;
|
||||
public:
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< boost::is_void<char_array_t>::value,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< ::boost::is_void<char_array_t>::value,
|
||||
boost::range_detail::std_container_,
|
||||
char_array_t >::type type;
|
||||
}; // class 'range'
|
||||
@ -114,3 +114,4 @@ namespace boost
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
|
||||
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/type_traits/remove_bounds.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// missing partial specialization workaround.
|
||||
@ -31,7 +31,7 @@ namespace boost
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME C::const_iterator type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -41,7 +41,7 @@ namespace boost
|
||||
template< typename P >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -53,61 +53,9 @@ namespace boost
|
||||
struct pts
|
||||
{
|
||||
typedef const BOOST_RANGE_DEDUCED_TYPENAME
|
||||
remove_bounds<T>::type* type;
|
||||
remove_extent<T>::type* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef const BOOST_RANGE_DEDUCED_TYPENAME
|
||||
remove_bounds<T>::type* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
|
376
include/boost/range/detail/detail_str.hpp
Executable file
376
include/boost/range/detail/detail_str.hpp
Executable file
@ -0,0 +1,376 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_DETAIL_STR_HPP
|
||||
#define BOOST_RANGE_DETAIL_DETAIL_STR_HPP
|
||||
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace range_detail
|
||||
{
|
||||
//
|
||||
// iterator
|
||||
//
|
||||
|
||||
template<>
|
||||
struct range_iterator_<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
remove_extent<T>::type* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// const iterator
|
||||
//
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef const BOOST_RANGE_DEDUCED_TYPENAME
|
||||
remove_extent<T>::type* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <boost/range/detail/begin.hpp>
|
||||
#include <boost/range/detail/end.hpp>
|
||||
#include <boost/range/detail/size_type>
|
||||
#include <boost/range/detail/value_type>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace range_detail
|
||||
{
|
||||
//
|
||||
// str_begin()
|
||||
//
|
||||
template<>
|
||||
struct range_begin<char_ptr_>
|
||||
{
|
||||
static char* fun( char* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_begin<const_char_ptr_>
|
||||
{
|
||||
static const char* fun( const char* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_begin<wchar_t_ptr_>
|
||||
{
|
||||
|
||||
static wchar_t* fun( wchar_t* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_begin<const_wchar_t_ptr_>
|
||||
{
|
||||
static const wchar_t* fun( const wchar_t* s )
|
||||
{
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
str_begin( C& c )
|
||||
{
|
||||
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail::range<C>::type >::fun( c );
|
||||
}
|
||||
|
||||
//
|
||||
// str_end()
|
||||
//
|
||||
|
||||
template<>
|
||||
struct range_end<char_array_>
|
||||
{
|
||||
template< typename T, std::size_t sz >
|
||||
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return boost::range_detail::array_end( boost_range_array );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_array_>
|
||||
{
|
||||
template< typename T, std::size_t sz >
|
||||
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return boost::range_detail::array_end( boost_range_array );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<char_ptr_>
|
||||
{
|
||||
static char* fun( char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<const_char_ptr_>
|
||||
{
|
||||
static const char* fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_ptr_>
|
||||
{
|
||||
static wchar_t* fun( wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<const_wchar_t_ptr_>
|
||||
{
|
||||
static const wchar_t* fun( const wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
str_end( C& c )
|
||||
{
|
||||
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail::range<C>::type >::fun( c );
|
||||
}
|
||||
|
||||
//
|
||||
// size_type
|
||||
//
|
||||
|
||||
template<>
|
||||
struct range_size_type_<char_array_>
|
||||
{
|
||||
template< typename A >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// value_type
|
||||
//
|
||||
|
||||
template<>
|
||||
struct range_value_type_<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef char type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef char type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef wchar_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
@ -58,7 +58,7 @@ namespace boost
|
||||
template< typename T, std::size_t sz >
|
||||
static bool fun( T BOOST_ARRAY_REF[sz] )
|
||||
{
|
||||
if( array == 0 )
|
||||
if( boost_range_array == 0 )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -11,9 +11,18 @@
|
||||
#ifndef BOOST_RANGE_DETAIL_END_HPP
|
||||
#define BOOST_RANGE_DETAIL_END_HPP
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# include <boost/range/detail/vc6/end.hpp>
|
||||
#else
|
||||
# include <boost/range/detail/implementation_help.hpp>
|
||||
# include <boost/range/iterator.hpp>
|
||||
# include <boost/range/detail/common.hpp>
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
|
||||
# include <boost/range/detail/remove_extent.hpp>
|
||||
# endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -30,7 +39,7 @@ namespace boost
|
||||
struct range_end<std_container_>
|
||||
{
|
||||
template< typename C >
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
fun( C& c )
|
||||
{
|
||||
return c.end();
|
||||
@ -45,7 +54,7 @@ namespace boost
|
||||
struct range_end<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return p.second;
|
||||
@ -59,85 +68,31 @@ namespace boost
|
||||
template<>
|
||||
struct range_end<array_>
|
||||
{
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
|
||||
template< typename T, std::size_t sz >
|
||||
static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return boost::range_detail::array_end( array );
|
||||
return boost::range_detail::array_end( boost_range_array );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<char_array_>
|
||||
{
|
||||
template< typename T, std::size_t sz >
|
||||
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
#else
|
||||
template<typename T>
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
|
||||
{
|
||||
return boost::range_detail::array_end( array );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_array_>
|
||||
{
|
||||
template< typename T, std::size_t sz >
|
||||
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return boost::range_detail::array_end( array );
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<char_ptr_>
|
||||
{
|
||||
static char* fun( char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<const_char_ptr_>
|
||||
{
|
||||
static const char* fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_ptr_>
|
||||
{
|
||||
static wchar_t* fun( wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<const_wchar_t_ptr_>
|
||||
{
|
||||
static const wchar_t* fun( const wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
|
||||
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
end( C& c )
|
||||
{
|
||||
return range_detail::range_end< BOOST_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
|
||||
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
# endif // VC6
|
||||
#endif
|
||||
|
@ -43,7 +43,7 @@ namespace boost
|
||||
#else
|
||||
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
|
||||
{
|
||||
if( s == 0 && s[0] == 0 )
|
||||
if( s == 0 || s[0] == 0 )
|
||||
return s;
|
||||
while( *++s != 0 )
|
||||
;
|
||||
@ -54,51 +54,59 @@ namespace boost
|
||||
template< class Char >
|
||||
inline Char* str_end( Char* s )
|
||||
{
|
||||
return (Char*)str_end( s, s );
|
||||
return const_cast<Char*>( str_end( s, s ) );
|
||||
}
|
||||
|
||||
/*
|
||||
template< class T, std::size_t sz >
|
||||
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], int )
|
||||
{
|
||||
return array + sz;
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], int )
|
||||
{
|
||||
return array + sz;
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
|
||||
{
|
||||
return array + sz - 1;
|
||||
return boost_range_array + sz - 1;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
|
||||
{
|
||||
return array + sz - 1;
|
||||
return boost_range_array + sz - 1;
|
||||
}
|
||||
*/
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
/*
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
|
||||
char_or_wchar_t_array_tag,
|
||||
int >::type tag;
|
||||
|
||||
return array_end<T,sz>( array, tag() );
|
||||
return array_end<T,sz>( boost_range_array, tag() );
|
||||
*/
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
/*
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
|
||||
char_or_wchar_t_array_tag,
|
||||
int >::type tag;
|
||||
|
||||
return array_end<T,sz>( array, tag() );
|
||||
return array_end<T,sz>( boost_range_array, tag() );
|
||||
*/
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -110,7 +118,8 @@ namespace boost
|
||||
{
|
||||
return str_end( s ) - s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
template< class T, std::size_t sz >
|
||||
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], int )
|
||||
{
|
||||
@ -134,24 +143,31 @@ namespace boost
|
||||
{
|
||||
return sz - 1;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
/*
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<const char,T>::value || is_same<const wchar_t,T>::value ||
|
||||
is_same<char,T>::value || is_same<wchar_t,T>::value,
|
||||
char_or_wchar_t_array_tag,
|
||||
int >::type tag;
|
||||
return array_size<T,sz>( array, tag() );
|
||||
return array_size<T,sz>( boost_range_array, tag() );
|
||||
*/
|
||||
return sz;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
/*
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
|
||||
char_or_wchar_t_array_tag,
|
||||
int >::type tag;
|
||||
return array_size<T,sz>( array, tag() );
|
||||
return array_size<T,sz>( boost_range_array, tag() );
|
||||
*/
|
||||
return sz;
|
||||
}
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
@ -12,7 +12,9 @@
|
||||
#define BOOST_RANGE_DETAIL_ITERATOR_HPP
|
||||
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/type_traits/remove_bounds.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// missing partial specialization workaround.
|
||||
@ -23,7 +25,13 @@ namespace boost
|
||||
namespace range_detail
|
||||
{
|
||||
template< typename T >
|
||||
struct range_iterator_;
|
||||
struct range_iterator_ {
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<std_container_>
|
||||
@ -31,7 +39,7 @@ namespace boost
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -41,7 +49,7 @@ namespace boost
|
||||
template< typename P >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -52,69 +60,18 @@ namespace boost
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
remove_bounds<T>::type* type;
|
||||
remove_extent<T>::type* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
remove_bounds<T>::type* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
template< typename C >
|
||||
class range_iterator
|
||||
class range_mutable_iterator
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
|
||||
typedef typename range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
|
||||
};
|
||||
}
|
||||
|
||||
|
97
include/boost/range/detail/mfc/carray.hpp
Executable file
97
include/boost/range/detail/mfc/carray.hpp
Executable file
@ -0,0 +1,97 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#if !defined( BOOST_RANGE_DETAIL_MFC_CARRAY_HPP ) && defined( BOOST_RANGE_ENABLE_MCF_CARRAY )
|
||||
#define BOOST_RANGE_DETAIL_MFC_CARRAY_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <afxtempl.h> // for CArray
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T, class U >
|
||||
struct range_iterator< CArray<T,U> >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
//
|
||||
// Why is this needed?!?
|
||||
//
|
||||
template< class T, class U >
|
||||
struct range_iterator< const CArray<T,U> >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct range_const_iterator< CArray<T,U> >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct range_difference< CArray<T,U> >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct range_size< CArray<T,U> >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
struct range_value< CArray<T,U> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template< class T, class U >
|
||||
T* boost_range_begin( CArray<T,U>& r )
|
||||
{
|
||||
return r.GetData();
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
const T* boost_range_begin( const CArray<T,U>& r )
|
||||
{
|
||||
return r.GetData();
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
int boost_range_size( const CArray<T,U>& r )
|
||||
{
|
||||
return r.GetSize();
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
T* boost_range_end( CArray<T,U>& r )
|
||||
{
|
||||
return boost_range_begin( r ) + boost_range_size( r );
|
||||
}
|
||||
|
||||
template< class T, class U >
|
||||
const T* boost_range_end( const CArray<T,U>& r )
|
||||
{
|
||||
return boost_range_begin( r ) + boost_range_size( r );
|
||||
}
|
||||
|
||||
// default 'empty()' ok
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
92
include/boost/range/detail/mfc/cstring.hpp
Executable file
92
include/boost/range/detail/mfc/cstring.hpp
Executable file
@ -0,0 +1,92 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#if !defined(BOOST_RANGE_DETAIL_MFC_CSTRING_HPP) && defined(BOOST_RANGE_ENABLE_MFC)
|
||||
#define BOOST_RANGE_DETAIL_MFC_CSTRING_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <afx.h> // for CString
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template<>
|
||||
struct range_iterator< CString >
|
||||
{
|
||||
typedef TCHAR* type;
|
||||
};
|
||||
|
||||
//
|
||||
// Why is this needed?!?
|
||||
//
|
||||
template<>
|
||||
struct range_iterator< const CString >
|
||||
{
|
||||
typedef TCHAR* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_const_iterator< CString >
|
||||
{
|
||||
typedef const TCHAR* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_difference< CString >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size< CString >
|
||||
{
|
||||
typedef int type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value< CString >
|
||||
{
|
||||
typedef TCHAR type;
|
||||
};
|
||||
|
||||
TCHAR* boost_range_begin( CString& r )
|
||||
{
|
||||
return r.GetBuffer(0);
|
||||
}
|
||||
|
||||
const TCHAR* boost_range_begin( const CString& r )
|
||||
{
|
||||
return (LPCTSTR)r;
|
||||
}
|
||||
|
||||
int boost_range_size( const CString& r )
|
||||
{
|
||||
return r.GetLength();
|
||||
}
|
||||
|
||||
TCHAR* boost_range_end( CString& r )
|
||||
{
|
||||
return boost_range_begin( r ) + boost_range_size( r );
|
||||
}
|
||||
|
||||
const TCHAR* range_adl_end( const CString& r )
|
||||
{
|
||||
return boost_range_begin( r ) + boost_range_size( r );
|
||||
}
|
||||
|
||||
// default 'empty()' ok
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
157
include/boost/range/detail/remove_extent.hpp
Executable file
157
include/boost/range/detail/remove_extent.hpp
Executable file
@ -0,0 +1,157 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Jonathan Turkanis 2005. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
|
||||
#define BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP
|
||||
|
||||
#include <boost/config.hpp> // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std.
|
||||
#include <cstddef>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
template< typename Case1 = mpl::true_,
|
||||
typename Type1 = mpl::void_,
|
||||
typename Case2 = mpl::true_,
|
||||
typename Type2 = mpl::void_,
|
||||
typename Case3 = mpl::true_,
|
||||
typename Type3 = mpl::void_,
|
||||
typename Case4 = mpl::true_,
|
||||
typename Type4 = mpl::void_,
|
||||
typename Case5 = mpl::true_,
|
||||
typename Type5 = mpl::void_,
|
||||
typename Case6 = mpl::true_,
|
||||
typename Type6 = mpl::void_,
|
||||
typename Case7 = mpl::true_,
|
||||
typename Type7 = mpl::void_,
|
||||
typename Case8 = mpl::true_,
|
||||
typename Type8 = mpl::void_,
|
||||
typename Case9 = mpl::true_,
|
||||
typename Type9 = mpl::void_,
|
||||
typename Case10 = mpl::true_,
|
||||
typename Type10 = mpl::void_,
|
||||
typename Case11 = mpl::true_,
|
||||
typename Type11 = mpl::void_,
|
||||
typename Case12 = mpl::true_,
|
||||
typename Type12 = mpl::void_,
|
||||
typename Case13 = mpl::true_,
|
||||
typename Type13 = mpl::void_,
|
||||
typename Case14 = mpl::true_,
|
||||
typename Type14 = mpl::void_,
|
||||
typename Case15 = mpl::true_,
|
||||
typename Type15 = mpl::void_,
|
||||
typename Case16 = mpl::true_,
|
||||
typename Type16 = mpl::void_,
|
||||
typename Case17 = mpl::true_,
|
||||
typename Type17 = mpl::void_,
|
||||
typename Case18 = mpl::true_,
|
||||
typename Type18 = mpl::void_,
|
||||
typename Case19 = mpl::true_,
|
||||
typename Type19 = mpl::void_,
|
||||
typename Case20 = mpl::true_,
|
||||
typename Type20 = mpl::void_>
|
||||
struct select {
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
Case1, mpl::identity<Type1>, mpl::eval_if<
|
||||
Case2, mpl::identity<Type2>, mpl::eval_if<
|
||||
Case3, mpl::identity<Type3>, mpl::eval_if<
|
||||
Case4, mpl::identity<Type4>, mpl::eval_if<
|
||||
Case5, mpl::identity<Type5>, mpl::eval_if<
|
||||
Case6, mpl::identity<Type6>, mpl::eval_if<
|
||||
Case7, mpl::identity<Type7>, mpl::eval_if<
|
||||
Case8, mpl::identity<Type8>, mpl::eval_if<
|
||||
Case9, mpl::identity<Type9>, mpl::if_<
|
||||
Case10, Type10, mpl::void_ > > > > > > > > >
|
||||
>::type result1;
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
Case11, mpl::identity<Type11>, mpl::eval_if<
|
||||
Case12, mpl::identity<Type12>, mpl::eval_if<
|
||||
Case13, mpl::identity<Type13>, mpl::eval_if<
|
||||
Case14, mpl::identity<Type14>, mpl::eval_if<
|
||||
Case15, mpl::identity<Type15>, mpl::eval_if<
|
||||
Case16, mpl::identity<Type16>, mpl::eval_if<
|
||||
Case17, mpl::identity<Type17>, mpl::eval_if<
|
||||
Case18, mpl::identity<Type18>, mpl::eval_if<
|
||||
Case19, mpl::identity<Type19>, mpl::if_<
|
||||
Case20, Type20, mpl::void_ > > > > > > > > >
|
||||
> result2;
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_same<result1, mpl::void_>,
|
||||
result2,
|
||||
mpl::identity<result1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct remove_extent {
|
||||
static T* ar;
|
||||
BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0]));
|
||||
|
||||
typedef typename
|
||||
select<
|
||||
is_same<T, bool[size]>, bool,
|
||||
is_same<T, char[size]>, char,
|
||||
is_same<T, signed char[size]>, signed char,
|
||||
is_same<T, unsigned char[size]>, unsigned char,
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
is_same<T, wchar_t[size]>, wchar_t,
|
||||
#endif
|
||||
is_same<T, short[size]>, short,
|
||||
is_same<T, unsigned short[size]>, unsigned short,
|
||||
is_same<T, int[size]>, int,
|
||||
is_same<T, unsigned int[size]>, unsigned int,
|
||||
is_same<T, long[size]>, long,
|
||||
is_same<T, unsigned long[size]>, unsigned long,
|
||||
is_same<T, float[size]>, float,
|
||||
is_same<T, double[size]>, double,
|
||||
is_same<T, long double[size]>, long double
|
||||
>::type result1;
|
||||
typedef typename
|
||||
select<
|
||||
is_same<T, const bool[size]>, const bool,
|
||||
is_same<T, const char[size]>, const char,
|
||||
is_same<T, const signed char[size]>, const signed char,
|
||||
is_same<T, const unsigned char[size]>, const unsigned char,
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
is_same<T, const wchar_t[size]>, const wchar_t,
|
||||
#endif
|
||||
is_same<T, const short[size]>, const short,
|
||||
is_same<T, const unsigned short[size]>, const unsigned short,
|
||||
is_same<T, const int[size]>, const int,
|
||||
is_same<T, const unsigned int[size]>, const unsigned int,
|
||||
is_same<T, const long[size]>, const long,
|
||||
is_same<T, const unsigned long[size]>, const unsigned long,
|
||||
is_same<T, const float[size]>, const float,
|
||||
is_same<T, const double[size]>, const double,
|
||||
is_same<T, const long double[size]>, const long double
|
||||
> result2;
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_same<result1, mpl::void_>,
|
||||
result2,
|
||||
mpl::identity<result1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
@ -12,10 +12,18 @@
|
||||
#ifndef BOOST_RANGE_DETAIL_SIZE_HPP
|
||||
#define BOOST_RANGE_DETAIL_SIZE_HPP
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/detail/size_type.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <iterator>
|
||||
#include <boost/config.hpp> // BOOST_MSVC
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
# include <boost/range/detail/vc6/size.hpp>
|
||||
#else
|
||||
# include <boost/range/detail/implementation_help.hpp>
|
||||
# include <boost/range/detail/size_type.hpp>
|
||||
# include <boost/range/detail/common.hpp>
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
|
||||
# include <boost/range/detail/remove_extent.hpp>
|
||||
# endif
|
||||
# include <iterator>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -60,11 +68,19 @@ namespace boost
|
||||
template<>
|
||||
struct range_size_<array_>
|
||||
{
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
template< typename T, std::size_t sz >
|
||||
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
#else
|
||||
template<typename T>
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return remove_extent<T>::size;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template<>
|
||||
@ -73,7 +89,7 @@ namespace boost
|
||||
template< typename T, std::size_t sz >
|
||||
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return boost::range_detail::array_size( array );
|
||||
return boost::range_detail::array_size( boost_range_array );
|
||||
}
|
||||
};
|
||||
|
||||
@ -83,7 +99,7 @@ namespace boost
|
||||
template< typename T, std::size_t sz >
|
||||
static std::size_t fun( T BOOST_RANGE_ARRAY_REF()[sz] )
|
||||
{
|
||||
return boost::range_detail::array_size( array );
|
||||
return boost::range_detail::array_size( boost_range_array );
|
||||
}
|
||||
};
|
||||
|
||||
@ -139,5 +155,5 @@ namespace boost
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
@ -30,7 +30,7 @@ namespace boost
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME C::size_type type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -54,63 +54,15 @@ namespace boost
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<char_array_>
|
||||
{
|
||||
template< typename A >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_type_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
class range_size
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
|
||||
typedef typename range_detail::range<C>::type c_type;
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
|
||||
typedef typename range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
|
||||
};
|
||||
}
|
||||
|
||||
|
38
include/boost/range/detail/str_types.hpp
Executable file
38
include/boost/range/detail/str_types.hpp
Executable file
@ -0,0 +1,38 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_STR_TYPES_HPP
|
||||
#define BOOST_RANGE_DETAIL_STR_TYPES_HPP
|
||||
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_mutable_iterator<T*>
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct range_const_iterator<T*>
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
struct range_size<T*>
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -12,7 +12,7 @@
|
||||
#define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
|
||||
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/type_traits/remove_bounds.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -32,7 +32,7 @@ namespace boost
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME C::value_type type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -42,7 +42,7 @@ namespace boost
|
||||
template< typename P >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_value< BOOST_RANGE_DEDUCED_TYPENAME P::first_type >::type type;
|
||||
};
|
||||
};
|
||||
|
||||
@ -52,60 +52,10 @@ namespace boost
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::remove_bounds<T>::type type;
|
||||
typedef BOOST_DEDUCED_TYPENAME remove_extent<T>::type type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct pts
|
||||
{
|
||||
typedef char type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef char type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<const_char_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const char type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef wchar_t type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value_type_<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename S >
|
||||
struct pts
|
||||
{
|
||||
typedef const wchar_t type;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
|
170
include/boost/range/detail/vc6/end.hpp
Executable file
170
include/boost/range/detail/vc6/end.hpp
Executable file
@ -0,0 +1,170 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_VC6_END_HPP
|
||||
#define BOOST_RANGE_DETAIL_VC6_END_HPP
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template< typename T >
|
||||
struct range_end;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<std_container_>
|
||||
{
|
||||
template< typename C >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
|
||||
fun( C& c )
|
||||
{
|
||||
return c.end();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
|
||||
fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
|
||||
fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
|
||||
fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<char_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static char* fun( char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<const_char_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static const char* fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static wchar_t* fun( wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<const_wchar_t_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static const wchar_t* fun( const wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
|
||||
end( C& c )
|
||||
{
|
||||
return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
166
include/boost/range/detail/vc6/size.hpp
Executable file
166
include/boost/range/detail/vc6/size.hpp
Executable file
@ -0,0 +1,166 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
|
||||
#ifndef BOOST_RANGE_DETAIL_VC6_SIZE_HPP
|
||||
#define BOOST_RANGE_DETAIL_VC6_SIZE_HPP
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/detail/size_type.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template< typename T >
|
||||
struct range_size_;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_size_<std_container_>
|
||||
{
|
||||
template< typename C >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c )
|
||||
{
|
||||
return c.size();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_size_<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return std::distance( p.first, p.second );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_size_<array_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<char_array_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return sizeof(T) / sizeof(T[0]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<wchar_t_array_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return sizeof(T) / sizeof(T[0]);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_size_<char_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<const_char_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<wchar_t_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<const_wchar_t_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
|
||||
template< typename C >
|
||||
BOOST_RANGE_DEDUCED_TYPENAME range_size<C>::type
|
||||
size( const C& c )
|
||||
{
|
||||
return range_detail::range_size_<range_detail::range<C>::type>::inner<C>::fun( c );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
@ -16,92 +16,14 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/difference_type.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_difference
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_difference< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_difference<Iterator>::type type;
|
||||
};
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_difference< const std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_difference<Iterator>::type type;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_difference< T[sz] >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_difference< const T[sz] >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_difference< char* >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_difference< wchar_t* >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_difference< const char* >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_difference< const wchar_t* >
|
||||
{
|
||||
typedef std::ptrdiff_t type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template< class T >
|
||||
struct range_difference : iterator_difference< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
34
include/boost/range/distance.hpp
Executable file
34
include/boost/range/distance.hpp
Executable file
@ -0,0 +1,34 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_DISTANCE_HPP
|
||||
#define BOOST_RANGE_DISTANCE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type
|
||||
distance( const T& r )
|
||||
{
|
||||
return std::distance( boost::begin( r ), boost::end( r ) );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
@ -16,52 +16,19 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
//#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
//#include <boost/range/detail/empty.hpp>
|
||||
//#else
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// primary template
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
inline bool empty( const C& c )
|
||||
{
|
||||
return boost::begin( c ) == boost::end( c );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline bool empty( const char* const& s )
|
||||
{
|
||||
return s == 0 || s[0] == 0;
|
||||
}
|
||||
|
||||
inline bool empty( const wchar_t* const& s )
|
||||
{
|
||||
return s == 0 || s[0] == 0;
|
||||
}
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
template< class T >
|
||||
inline bool empty( const T& r )
|
||||
{
|
||||
return range_detail::empty( r );
|
||||
}
|
||||
template< class T >
|
||||
inline bool empty( const T& r )
|
||||
{
|
||||
return boost::begin( r ) == boost::end( r );
|
||||
}
|
||||
|
||||
} // namepace 'boost'
|
||||
|
||||
//#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
#endif
|
||||
|
@ -25,139 +25,85 @@
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
namespace range_detail
|
||||
{
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// primary template
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type
|
||||
end( const C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
|
||||
end( C& c )
|
||||
range_end( C& c )
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator end( const std::pair<Iterator,Iterator>& p )
|
||||
inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
|
||||
|
||||
template< typename Iterator >
|
||||
inline Iterator end( std::pair<Iterator,Iterator>& p )
|
||||
inline Iterator range_end( std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline const T* end( const T (&array)[sz] )
|
||||
inline const T* range_end( const T (&array)[sz] )
|
||||
{
|
||||
return range_detail::array_end<T,sz>( array );
|
||||
return range_detail::array_end<T,sz>( array );
|
||||
}
|
||||
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline T* end( T (&array)[sz] )
|
||||
inline T* range_end( T (&array)[sz] )
|
||||
{
|
||||
return range_detail::array_end<T,sz>( array );
|
||||
return range_detail::array_end<T,sz>( array );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 0x3204 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// CW up to 9.3 and borland have troubles with function ordering
|
||||
inline char* end( char* s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
|
||||
inline wchar_t* end( wchar_t* s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
|
||||
inline const char* end( const char* s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
|
||||
inline const wchar_t* end( const wchar_t* s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
#else
|
||||
inline char* end( char*& s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
|
||||
inline wchar_t* end( wchar_t*& s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
|
||||
inline const char* end( const char*& s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
|
||||
inline const wchar_t* end( const wchar_t*& s )
|
||||
{
|
||||
return range_detail::str_end( s );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
} // namespace 'range_detail'
|
||||
#endif
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
|
||||
{
|
||||
return range_detail::end( r );
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_end( r );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type end( const T& r )
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
|
||||
{
|
||||
return range_detail::end( r );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// BCB and CW are not able to overload pointer when class overloads are also available.
|
||||
template<>
|
||||
inline range_const_iterator<const char*>::type end<const char*>( const char*& r )
|
||||
{
|
||||
return range_detail::str_end( r );
|
||||
}
|
||||
|
||||
template<>
|
||||
inline range_const_iterator<const wchar_t*>::type end<const wchar_t*>( const wchar_t*& r )
|
||||
{
|
||||
return range_detail::str_end( r );
|
||||
}
|
||||
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
/**/
|
||||
using namespace range_detail;
|
||||
#endif
|
||||
return range_end( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
@ -169,11 +115,12 @@ inline range_const_iterator<const wchar_t*>::type end<const wchar_t*>( const wch
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
|
||||
const_end( const T& r )
|
||||
{
|
||||
return end( r );
|
||||
return boost::end( r );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -18,8 +18,10 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/size.hpp>
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/rbegin.hpp>
|
||||
#include <boost/range/rend.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -11,94 +11,30 @@
|
||||
#ifndef BOOST_RANGE_ITERATOR_HPP
|
||||
#define BOOST_RANGE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/iterator.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <boost/range/mutable_iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_iterator< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_iterator< const std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_iterator< T[sz] >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_iterator< const T[sz] >
|
||||
{
|
||||
typedef const T* type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_iterator< char* >
|
||||
{
|
||||
typedef char* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator< wchar_t* >
|
||||
{
|
||||
typedef wchar_t* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator< const char* >
|
||||
{
|
||||
typedef const char* type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator< const wchar_t* >
|
||||
{
|
||||
typedef const wchar_t* type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
||||
|
@ -11,13 +11,29 @@
|
||||
#ifndef BOOST_RANGE_ITERATOR_RANGE_HPP
|
||||
#define BOOST_RANGE_ITERATOR_RANGE_HPP
|
||||
|
||||
// From boost/dynamic_bitset.hpp; thanks to Matthias Troyer for Cray X1 patch.
|
||||
#include <boost/config.hpp> // Define __STL_CONFIG_H, if appropriate.
|
||||
#ifndef BOOST_OLD_IOSTREAMS
|
||||
# if defined(__STL_CONFIG_H) && \
|
||||
!defined (__STL_USE_NEW_IOSTREAMS) && !defined(__crayx1) \
|
||||
/**/
|
||||
# define BOOST_OLD_IOSTREAMS
|
||||
# endif
|
||||
#endif // #ifndef BOOST_OLD_IOSTREAMS
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
#ifndef BOOST_OLD_IOSTREAMS
|
||||
# include <ostream>
|
||||
#else
|
||||
# include <ostream.h>
|
||||
#endif
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
@ -27,14 +43,35 @@
|
||||
a rich subset of Container interface.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace range_detail
|
||||
namespace boost
|
||||
{
|
||||
namespace iterator_range_detail
|
||||
{
|
||||
//
|
||||
// The functions adl_begin and adl_end are implemented in a separate
|
||||
// class for gcc-2.9x
|
||||
//
|
||||
template<typename IteratorT>
|
||||
struct iterator_range_impl {
|
||||
template< class ForwardRange >
|
||||
static IteratorT adl_begin( ForwardRange& r )
|
||||
{
|
||||
return IteratorT( boost::begin( r ) );
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
static IteratorT adl_end( ForwardRange& r )
|
||||
{
|
||||
return IteratorT( boost::end( r ) );
|
||||
}
|
||||
};
|
||||
|
||||
template< class Left, class Right >
|
||||
inline bool equal( const Left& l, const Right& r )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_size<Left>::type sz_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME boost::range_size<Left>::type sz_type;
|
||||
|
||||
sz_type l_size = boost::size( l ),
|
||||
r_size = boost::size( r );
|
||||
|
||||
@ -53,6 +90,10 @@ namespace boost {
|
||||
boost::begin(r),
|
||||
boost::end(r) );
|
||||
}
|
||||
|
||||
struct range_tag { };
|
||||
struct const_range_tag { };
|
||||
|
||||
}
|
||||
|
||||
// iterator range template class -----------------------------------------//
|
||||
@ -77,11 +118,15 @@ namespace boost {
|
||||
template<typename IteratorT>
|
||||
class iterator_range
|
||||
{
|
||||
protected: // Used by sub_range
|
||||
//! implementation class
|
||||
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
|
||||
public:
|
||||
|
||||
//! this type
|
||||
typedef iterator_range<IteratorT> type;
|
||||
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
|
||||
|
||||
|
||||
//! Encapsulated value type
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type value_type;
|
||||
@ -89,8 +134,20 @@ namespace boost {
|
||||
//! Difference type
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_difference<IteratorT>::type difference_type;
|
||||
|
||||
//! Size type
|
||||
typedef std::size_t size_type; // note: must be unsigned
|
||||
|
||||
//! This type
|
||||
typedef iterator_range<IteratorT> this_type;
|
||||
|
||||
//! Refence type
|
||||
//
|
||||
// Needed because value-type is the same for
|
||||
// const and non-const iterators
|
||||
//
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_reference<IteratorT>::type reference;
|
||||
|
||||
//! const_iterator type
|
||||
/*!
|
||||
@ -101,182 +158,245 @@ namespace boost {
|
||||
//! iterator type
|
||||
typedef IteratorT iterator;
|
||||
|
||||
iterator_range() : m_Begin( iterator() ), m_End( iterator() ),
|
||||
singular( true )
|
||||
iterator_range() : m_Begin( iterator() ), m_End( iterator() )
|
||||
#ifndef NDEBUG
|
||||
, singular( true )
|
||||
#endif
|
||||
{ }
|
||||
|
||||
/*
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
iterator_range( this_type r ) :
|
||||
: m_Begin(r.begin()), m_End(r.end())
|
||||
{ }
|
||||
|
||||
this_type& operator=( this_type r )
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
//! Constructor from a pair of iterators
|
||||
template< class Iterator >
|
||||
iterator_range( Iterator Begin, Iterator End ) :
|
||||
m_Begin(Begin), m_End(End), singular(false) {}
|
||||
m_Begin(Begin), m_End(End)
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( const Range& r ) :
|
||||
m_Begin( adl_begin( r ) ), m_End( adl_end( r ) ),
|
||||
singular(false) {}
|
||||
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( Range& r ) :
|
||||
m_Begin( adl_begin( r ) ), m_End( adl_end( r ) ),
|
||||
singular(false) {}
|
||||
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( Range& r, iterator_range_detail::range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
#ifndef NDEBUG
|
||||
, singular(false)
|
||||
#endif
|
||||
{}
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
this_type& operator=( const this_type& r )
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
|
||||
#ifndef NDEBUG
|
||||
singular = r.singular;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class Iterator >
|
||||
iterator_range& operator=( const iterator_range<Iterator>& r )
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
//
|
||||
// remark: this need not necessarily be true, but it does no harm
|
||||
//
|
||||
singular = r.empty();
|
||||
#ifndef NDEBUG
|
||||
singular = r.is_singular();
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator_range& operator=( ForwardRange& r )
|
||||
{
|
||||
m_Begin = adl_begin( r );
|
||||
m_End = adl_end( r );
|
||||
m_Begin = impl::adl_begin( r );
|
||||
m_End = impl::adl_end( r );
|
||||
#ifndef NDEBUG
|
||||
singular = false;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator_range& operator=( const ForwardRange& r )
|
||||
{
|
||||
m_Begin = adl_begin( r );
|
||||
m_End = adl_end( r );
|
||||
m_Begin = impl::adl_begin( r );
|
||||
m_End = impl::adl_end( r );
|
||||
#ifndef NDEBUG
|
||||
singular = false;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! begin access
|
||||
/*!
|
||||
Retrieve the begin iterator
|
||||
*/
|
||||
IteratorT begin() const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_Begin;
|
||||
}
|
||||
|
||||
//! end access
|
||||
/*!
|
||||
Retrieve the end iterator
|
||||
*/
|
||||
IteratorT end() const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_End;
|
||||
}
|
||||
|
||||
//! Size of the range
|
||||
/*!
|
||||
Retrieve the size of the range
|
||||
*/
|
||||
size_type size() const
|
||||
{
|
||||
if( singular )
|
||||
return 0;
|
||||
|
||||
return std::distance( m_Begin, m_End );
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_End - m_Begin;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
if( singular )
|
||||
return true;
|
||||
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_Begin == m_End;
|
||||
}
|
||||
|
||||
//! Safe bool conversion
|
||||
/*!
|
||||
Check whenever the range is empty.
|
||||
Allows to use construction like this:
|
||||
\code
|
||||
iterator_range r;
|
||||
if (!r)
|
||||
{
|
||||
...
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
operator bool() const
|
||||
{
|
||||
return !empty();
|
||||
}
|
||||
#else
|
||||
typedef iterator (iterator_range::*unspecified_bool_type) () const;
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return empty() ? 0: &iterator_range::end;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool equal( const iterator_range& r ) const
|
||||
{
|
||||
return singular == r.singular && m_Begin == r.m_Begin && m_End == r.m_End;
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return m_Begin == r.m_Begin && m_End == r.m_End;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
bool operator==( const iterator_range& r ) const
|
||||
{
|
||||
return range_detail::equal( *this, r );
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return iterator_range_detail::equal( *this, r );
|
||||
}
|
||||
|
||||
bool operator!=( const iterator_range& r ) const
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return !operator==(r);
|
||||
}
|
||||
|
||||
bool operator<( const iterator_range& r ) const
|
||||
{
|
||||
return range_detail::less_than( *this, r );
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
return iterator_range_detail::less_than( *this, r );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
template< class ForwardRange >
|
||||
iterator adl_begin( ForwardRange& r )
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
return boost::begin( r );
|
||||
#else
|
||||
using boost::begin;
|
||||
return iterator( begin( r ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator adl_end( ForwardRange& r )
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
return boost::end( r );
|
||||
#else
|
||||
using boost::end;
|
||||
return iterator( end( r ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public: // convenience
|
||||
reference front() const
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
return *m_Begin;
|
||||
}
|
||||
|
||||
reference back() const
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
IteratorT last( m_End );
|
||||
return *--last;
|
||||
}
|
||||
|
||||
reference operator[]( size_type sz ) const
|
||||
{
|
||||
BOOST_ASSERT( sz < size() );
|
||||
return m_Begin[sz];
|
||||
}
|
||||
|
||||
iterator_range& advance_begin( difference_type n )
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
std::advance( m_Begin, n );
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_range& advance_end( difference_type n )
|
||||
{
|
||||
BOOST_ASSERT( !is_singular() );
|
||||
std::advance( m_End, n );
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
// begin and end iterators
|
||||
IteratorT m_Begin;
|
||||
IteratorT m_End;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool singular;
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
public:
|
||||
bool is_singular() const
|
||||
{
|
||||
return singular;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
//
|
||||
// Allow subclasses an easy way to access the
|
||||
// base type
|
||||
//
|
||||
typedef iterator_range iterator_range_;
|
||||
};
|
||||
|
||||
// iterator range free-standing operators ---------------------------//
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#else
|
||||
template< class Iterator >
|
||||
inline bool empty( const iterator_range<Iterator>& r )
|
||||
{
|
||||
//
|
||||
// this will preserve the well-defined empty() even
|
||||
// though 'r' is singular.
|
||||
//
|
||||
return r.empty();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_OLD_IOSTREAMS
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputed
|
||||
@ -287,10 +407,31 @@ namespace boost {
|
||||
std::basic_ostream<Elem, Traits>& Os,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
std::copy( begin(r), end(r), std::ostream_iterator<Elem>(Os));
|
||||
std::copy( r.begin(), r.end(),
|
||||
std::ostream_iterator< BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type,
|
||||
Elem, Traits>(Os) );
|
||||
return Os;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//! iterator_range output operator
|
||||
/*!
|
||||
Output the range to an ostream. Elements are outputed
|
||||
in a sequence without separators.
|
||||
*/
|
||||
template< typename IteratorT >
|
||||
inline std::ostream& operator<<(
|
||||
std::ostream& Os,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
std::copy( r.begin(), r.end(), std::ostream_iterator<char>(Os));
|
||||
return Os;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// comparison operators
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -299,21 +440,21 @@ namespace boost {
|
||||
inline bool operator==( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return range_detail::equal( l, r );
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator!=( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return !range_detail::equal( l, r );
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return range_detail::less_than( l, r );
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
@ -322,14 +463,14 @@ namespace boost {
|
||||
inline bool operator==( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return range_detail::equal( l, r );
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator==( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return range_detail::equal( l, r );
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
|
||||
@ -337,14 +478,14 @@ namespace boost {
|
||||
inline bool operator!=( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return !range_detail::equal( l, r );
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator!=( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return !range_detail::equal( l, r );
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
|
||||
@ -352,16 +493,16 @@ namespace boost {
|
||||
inline bool operator<( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return range_detail::less_than( l, r );
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return range_detail::less_than( l, r );
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
// iterator range utilities -----------------------------------------//
|
||||
@ -380,16 +521,15 @@ namespace boost {
|
||||
{
|
||||
return iterator_range<IteratorT>( Begin, End );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< typename Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_iterator_range( Range& r )
|
||||
{
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
|
||||
( begin( r ), end( r ) );
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
( boost::begin( r ), boost::end( r ) );
|
||||
}
|
||||
|
||||
#else
|
||||
@ -402,16 +542,76 @@ namespace boost {
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
make_iterator_range( ForwardRange& r )
|
||||
{
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
( r );
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
( r, iterator_range_detail::range_tag() );
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
|
||||
make_iterator_range( const ForwardRange& r )
|
||||
{
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type >
|
||||
( r );
|
||||
return iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type >
|
||||
( r, iterator_range_detail::const_range_tag() );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
namespace iterator_range_detail
|
||||
{
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_range_impl( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//
|
||||
// Not worth the effort
|
||||
//
|
||||
//if( advance_begin == 0 && advance_end == 0 )
|
||||
// return make_iterator_range( r );
|
||||
//
|
||||
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
|
||||
new_begin = boost::begin( r ),
|
||||
new_end = boost::end( r );
|
||||
std::advance( new_begin, advance_begin );
|
||||
std::advance( new_end, advance_end );
|
||||
return make_iterator_range( new_begin, new_end );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_iterator_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_iterator_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type >
|
||||
make_iterator_range( const Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
@ -427,27 +627,12 @@ namespace boost {
|
||||
template< typename SeqT, typename Range >
|
||||
inline SeqT copy_range( const Range& r )
|
||||
{
|
||||
return SeqT( begin( r ), end( r ) );
|
||||
}
|
||||
|
||||
//! transform a range into a sequence
|
||||
/*!
|
||||
Create a new sequence from the elements in the range, transformed
|
||||
by a function
|
||||
|
||||
\param Range An input range
|
||||
\param Func Transformation function
|
||||
\return New sequence
|
||||
*/
|
||||
template< typename SeqT, typename Range, typename FuncT >
|
||||
inline SeqT transform_range( const Range& r, FuncT Func )
|
||||
{
|
||||
SeqT Seq;
|
||||
std::transform( begin( r ), end( r ), std::back_inserter(Seq), Func );
|
||||
return Seq;
|
||||
return SeqT( boost::begin( r ), boost::end( r ) );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#undef BOOST_OLD_IOSTREAMS
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -16,13 +16,15 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
#include <boost/range/const_reverse_iterator.hpp>
|
||||
#include <boost/range/reverse_result_iterator.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/category.hpp>
|
||||
#include <boost/range/reference.hpp>
|
||||
#include <boost/range/pointer.hpp>
|
||||
|
||||
#endif
|
||||
|
64
include/boost/range/mutable_iterator.hpp
Executable file
64
include/boost/range/mutable_iterator.hpp
Executable file
@ -0,0 +1,64 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_MUTABLE_ITERATOR_HPP
|
||||
#define BOOST_RANGE_MUTABLE_ITERATOR_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/iterator.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_mutable_iterator
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_mutable_iterator< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef Iterator type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_mutable_iterator< T[sz] >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
29
include/boost/range/pointer.hpp
Executable file
29
include/boost/range/pointer.hpp
Executable file
@ -0,0 +1,29 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2006. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_POINTER_TYPE_HPP
|
||||
#define BOOST_RANGE_POINTER_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_pointer : iterator_pointer< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
@ -16,9 +16,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/reverse_result_iterator.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
#include <boost/range/const_reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -26,41 +24,42 @@ namespace boost
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rbegin( C& c )
|
||||
{
|
||||
return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type( end( c ) );
|
||||
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::end( c ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rbegin( C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
iter_type;
|
||||
return iter_type( end( c ) );
|
||||
return iter_type( boost::end( c ) );
|
||||
}
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
rbegin( const C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
iter_type;
|
||||
return iter_type( end( c ) );
|
||||
return iter_type( boost::end( c ) );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<T>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
|
||||
const_rbegin( const T& r )
|
||||
{
|
||||
return rbegin( r );
|
||||
return boost::rbegin( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
|
||||
|
29
include/boost/range/reference.hpp
Executable file
29
include/boost/range/reference.hpp
Executable file
@ -0,0 +1,29 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#ifndef BOOST_RANGE_REFERENCE_TYPE_HPP
|
||||
#define BOOST_RANGE_REFERENCE_TYPE_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class T >
|
||||
struct range_reference : iterator_reference< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
@ -16,51 +16,50 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/reverse_result_iterator.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
#include <boost/range/const_reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rend( C& c )
|
||||
{
|
||||
return BOOST_DEDUCED_TYPENAME range_reverse_result_iterator<C>::type( begin( c ) );
|
||||
return BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type( boost::begin( c ) );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
rend( C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<C>::type
|
||||
iter_type;
|
||||
return iter_type( begin( c ) );
|
||||
return iter_type( boost::begin( c ) );
|
||||
}
|
||||
|
||||
template< class C >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
rend( const C& c )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<C>::type
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reverse_iterator<const C>::type
|
||||
iter_type;
|
||||
return iter_type( begin( c ) );
|
||||
return iter_type( boost::begin( c ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_const_reverse_iterator<T>::type
|
||||
inline BOOST_DEDUCED_TYPENAME range_reverse_iterator<const T>::type
|
||||
const_rend( const T& r )
|
||||
{
|
||||
return rend( r );
|
||||
return boost::rend( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -15,29 +15,19 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This interface is deprecated, use range_iterator<T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_result_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::if_< BOOST_DEDUCED_TYPENAME is_const<C>::type,
|
||||
BOOST_DEDUCED_TYPENAME range_const_iterator<C>::type,
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<C>::type >::type type;
|
||||
};
|
||||
struct range_result_iterator : range_iterator<C>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
||||
|
@ -15,25 +15,18 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
#include <boost/range/reverse_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This interface is deprecated, use range_reverse_iterator<T>
|
||||
//
|
||||
|
||||
template< typename C >
|
||||
struct range_reverse_result_iterator
|
||||
{
|
||||
typedef reverse_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type > type;
|
||||
};
|
||||
struct range_reverse_result_iterator : range_reverse_iterator<C>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#endif
|
||||
|
@ -15,102 +15,19 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#include <boost/range/detail/size.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// primary template
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
inline BOOST_DEDUCED_TYPENAME C::size_type
|
||||
size( const C& c )
|
||||
{
|
||||
return c.size();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
inline std::size_t size( const std::pair<Iterator,Iterator>& p )
|
||||
{
|
||||
return std::distance( p.first, p.second );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline std::size_t size( const T (&array)[sz] )
|
||||
{
|
||||
return range_detail::array_size<T,sz>( array );
|
||||
}
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
inline std::size_t size( T (&array)[sz] )
|
||||
{
|
||||
return boost::range_detail::array_size<T,sz>( array );
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline std::size_t size( const char* const& s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
|
||||
inline std::size_t size( const wchar_t* const& s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_size<T>::type size( const T& r )
|
||||
{
|
||||
return range_detail::size( r );
|
||||
}
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(__MWERKS__, <= 3003 ) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// BCB and CW are not able to overload pointer when class overloads are also available.
|
||||
inline range_size<const char*>::type size( const char* r ) {
|
||||
return range_detail::str_size( r );
|
||||
}
|
||||
inline range_size<char*>::type size( char* r ) {
|
||||
return range_detail::str_size( r );
|
||||
}
|
||||
inline range_size<const wchar_t*>::type size( const wchar_t* r ) {
|
||||
return range_detail::str_size( r );
|
||||
}
|
||||
inline range_size<wchar_t*>::type size( wchar_t* r ) {
|
||||
return range_detail::str_size( r );
|
||||
}
|
||||
#endif
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME range_size<T>::type size( const T& r )
|
||||
{
|
||||
return boost::end( r ) - boost::begin( r );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
#endif
|
||||
|
@ -21,83 +21,58 @@
|
||||
#include <boost/range/detail/size_type.hpp>
|
||||
#else
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
namespace detail
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_size
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
|
||||
};
|
||||
template< typename C >
|
||||
struct range_size
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_size< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_size< const std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
template< typename Iterator >
|
||||
struct range_size< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_size< T[sz] >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_size< T[sz] >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_size< const T[sz] >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_size< char* >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size< wchar_t* >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size< const char* >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size< const wchar_t* >
|
||||
{
|
||||
typedef std::size_t type;
|
||||
};
|
||||
template< class T >
|
||||
struct range_size :
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct range_size<const T > : range_size<T>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -14,35 +14,46 @@
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template< class ForwardRange >
|
||||
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type >
|
||||
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type iterator_t;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
|
||||
typedef iterator_range< iterator_t > base;
|
||||
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME base::impl impl;
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_result_iterator<ForwardRange>::type iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_const_iterator<ForwardRange>::type const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type const_iterator;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
|
||||
|
||||
public:
|
||||
sub_range() : base()
|
||||
{ }
|
||||
|
||||
|
||||
/*
|
||||
template< class ForwardRange2 >
|
||||
sub_range( sub_range<ForwardRange2> r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif */
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( ForwardRange2& r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( boost::begin( r ), boost::end( r ) )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
@ -52,7 +63,7 @@ namespace boost
|
||||
sub_range( const ForwardRange2& r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( boost::begin( r ), boost::end( r ) )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
@ -76,6 +87,16 @@ namespace boost
|
||||
base::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
|
||||
sub_range& operator=( sub_range r )
|
||||
{
|
||||
//
|
||||
// argument passed by value to avoid
|
||||
// const_iterator to iterator conversion
|
||||
//
|
||||
base::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@ -85,30 +106,63 @@ namespace boost
|
||||
const_iterator end() const { return base::end(); }
|
||||
size_type size() const { return base::size(); }
|
||||
|
||||
|
||||
public: // convenience
|
||||
value_type& front()
|
||||
{
|
||||
return base::front();
|
||||
}
|
||||
|
||||
const value_type& front() const
|
||||
{
|
||||
return base::front();
|
||||
}
|
||||
|
||||
value_type& back()
|
||||
{
|
||||
return base::back();
|
||||
}
|
||||
|
||||
const value_type& back() const
|
||||
{
|
||||
return base::back();
|
||||
}
|
||||
|
||||
value_type& operator[]( size_type sz )
|
||||
{
|
||||
return base::operator[](sz);
|
||||
}
|
||||
|
||||
const value_type& operator[]( size_type sz ) const
|
||||
{
|
||||
return base::operator[](sz);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template< class ForwardRange, class ForwardRange2 >
|
||||
inline bool operator==( const sub_range<ForwardRange>& l,
|
||||
const sub_range<ForwardRange2>& r )
|
||||
{
|
||||
return range_detail::equal( l, r );
|
||||
return iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class ForwardRange, class ForwardRange2 >
|
||||
inline bool operator!=( const sub_range<ForwardRange>& l,
|
||||
const sub_range<ForwardRange2>& r )
|
||||
{
|
||||
return !range_detail::equal( l, r );
|
||||
return !iterator_range_detail::equal( l, r );
|
||||
}
|
||||
|
||||
template< class ForwardRange, class ForwardRange2 >
|
||||
inline bool operator<( const sub_range<ForwardRange>& l,
|
||||
const sub_range<ForwardRange2>& r )
|
||||
{
|
||||
return range_detail::less_than( l, r );
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -16,93 +16,19 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
#include <boost/range/detail/value_type.hpp>
|
||||
#else
|
||||
//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
//#include <boost/range/detail/value_type.hpp>
|
||||
//#else
|
||||
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename C >
|
||||
struct range_value
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_value< std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<Iterator>::type type;
|
||||
};
|
||||
|
||||
|
||||
template< typename Iterator >
|
||||
struct range_value< const std::pair<Iterator,Iterator> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<Iterator>::type type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_value< T[sz] >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template< typename T, std::size_t sz >
|
||||
struct range_value< const T[sz] >
|
||||
{
|
||||
typedef const T type;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_value< char* >
|
||||
{
|
||||
typedef char type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value< wchar_t* >
|
||||
{
|
||||
typedef wchar_t type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value< const char* >
|
||||
{
|
||||
typedef const char type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_value< const wchar_t* >
|
||||
{
|
||||
typedef const wchar_t type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template< class T >
|
||||
struct range_value : iterator_value< typename range_iterator<T>::type >
|
||||
{ };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
16
index.html
16
index.html
@ -25,7 +25,7 @@
|
||||
(see <a href=http://www.boost.org/LICENSE_1_0.txt>
|
||||
http://www.boost.org/LICENSE_1_0.txt</a>).
|
||||
</p>
|
||||
|
||||
|
||||
<h1>Overview</h1>
|
||||
<p>
|
||||
Boost.Range is a collection of concepts and utilities that are particularly
|
||||
@ -34,22 +34,22 @@
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li> <a href=doc/intro.html>Introduction </a></code>
|
||||
<li> <a href="doc/intro.html">Introduction </a></code>
|
||||
|
||||
<li><a href=doc/range.html>Range concepts:</a>
|
||||
<li><a href="doc/range.html">Range concepts:</a>
|
||||
<ul>
|
||||
<li> <a href="doc/range.html#single_pass_range">SinglePassRange</a>
|
||||
<li> <a href="doc/range.html#range">ForwardRange</a>
|
||||
<li> <a href="doc/range.html#reversible_range">BidirectionalRange</a>
|
||||
<li> <a href="doc/range.html#forward_range">ForwardRange</a>
|
||||
<li> <a href="doc/range.html#bidirectional_range">BidirectionalRange</a>
|
||||
<li> <a href="doc/range.html#random_access_range">RandomAccessRange</a> </ul>
|
||||
|
||||
<li> <a href=doc/boost_range.html>Implementation</a> of Range concepts
|
||||
<li> <a href=doc/utility_class.html> Utilities:</a>
|
||||
<li> <a href="doc/boost_range.html">Reference</a>
|
||||
<li> <a href="doc/utility_class.html"> Utilities:</a>
|
||||
<ul>
|
||||
<li> Class <a href="doc/utility_class.html#iter_range"><code>iterator_range</code></a>
|
||||
<li> Class <a href="doc/utility_class.html#sub_range"><code>sub_range</code></a> </ul>
|
||||
|
||||
<li> <a href=doc/style.html>Terminology and style guidelines </a>
|
||||
<li> <a href="doc/style.html">Terminology and style guidelines </a>
|
||||
<li><a href="doc/headers.html">Headers</a> </li>
|
||||
<li><a href="doc/examples.html">Examples</a>
|
||||
<li><a href="doc/portability.html">Portability</a>
|
||||
|
103
test/Jamfile
103
test/Jamfile
@ -1,103 +0,0 @@
|
||||
# Boost.Range library
|
||||
#
|
||||
# Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
# distribution is subject to the Boost Software License, Version
|
||||
# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# For more information, see http://www.boost.org/libs/range/
|
||||
#
|
||||
|
||||
subproject libs/range/test ;
|
||||
|
||||
SEARCH on testing.jam = $(BOOST_BUILD_PATH) ;
|
||||
include testing.jam ;
|
||||
DEPENDS all : test ;
|
||||
|
||||
{
|
||||
test-suite range
|
||||
: [ run
|
||||
array.cpp
|
||||
: :
|
||||
:
|
||||
: array_test
|
||||
]
|
||||
[ run
|
||||
iterator_pair.cpp
|
||||
: :
|
||||
:
|
||||
: iterator_pair_test
|
||||
]
|
||||
[ run
|
||||
std_container.cpp
|
||||
: :
|
||||
:
|
||||
: std_container_test
|
||||
]
|
||||
[ run
|
||||
string.cpp
|
||||
: :
|
||||
:
|
||||
: string_test
|
||||
]
|
||||
[ run
|
||||
iterator_range.cpp
|
||||
: :
|
||||
:
|
||||
: iterator_range
|
||||
]
|
||||
[ run
|
||||
sub_range.cpp
|
||||
: :
|
||||
:
|
||||
: sub_range
|
||||
]
|
||||
|
||||
[ run
|
||||
partial_workaround.cpp
|
||||
: :
|
||||
:
|
||||
: workaround_test
|
||||
]
|
||||
[ run
|
||||
algorithm_example.cpp
|
||||
: :
|
||||
:
|
||||
: example_test
|
||||
]
|
||||
|
||||
[ run
|
||||
reversible_range.cpp
|
||||
: :
|
||||
:
|
||||
: reversible_range_test
|
||||
]
|
||||
[ run
|
||||
const_ranges.cpp
|
||||
: :
|
||||
:
|
||||
: const_ranges
|
||||
]
|
||||
# [ run
|
||||
# compat3.cpp
|
||||
# : :
|
||||
# :
|
||||
# : compat3_test
|
||||
# ]
|
||||
#
|
||||
# [ run
|
||||
# adl_conformance.cpp
|
||||
# : :
|
||||
# :
|
||||
# : adl_conformance
|
||||
# ]
|
||||
# [ run
|
||||
# adl_conformance_no_using.cpp
|
||||
# : :
|
||||
# :
|
||||
# : adl_conformance_no_using_declaration
|
||||
# ]
|
||||
|
||||
;
|
||||
|
||||
}
|
35
test/Jamfile.v2
Normal file
35
test/Jamfile.v2
Normal file
@ -0,0 +1,35 @@
|
||||
# Boost.Range library
|
||||
#
|
||||
# Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
# distribution is subject to the Boost Software License, Version
|
||||
# 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# For more information, see http://www.boost.org/libs/range/
|
||||
#
|
||||
|
||||
rule range-test ( name : includes * )
|
||||
{
|
||||
return [
|
||||
run $(name).cpp /boost/test//boost_unit_test_framework/<link>static
|
||||
:
|
||||
:
|
||||
: $(includes)
|
||||
] ;
|
||||
}
|
||||
|
||||
test-suite range :
|
||||
[ range-test array ]
|
||||
[ range-test iterator_pair ]
|
||||
[ range-test std_container ]
|
||||
[ range-test string ]
|
||||
[ range-test iterator_range ]
|
||||
[ range-test sub_range ]
|
||||
[ range-test partial_workaround ]
|
||||
[ range-test algorithm_example ]
|
||||
[ range-test reversible_range ]
|
||||
[ range-test const_ranges ]
|
||||
[ range-test extension_mechanism ]
|
||||
# [ range-test mfc : <include>$(VC71_ROOT)/atlmfc/include ]
|
||||
;
|
||||
|
110
test/TODO
110
test/TODO
@ -1,111 +1 @@
|
||||
17. post-review question: should Range mean lowest common denominator? or
|
||||
perhaps Forward Range? problem with not being explicit.
|
||||
|
||||
18. maybe iterator_range operator==() should be defined when rhs or lhs
|
||||
take a forward range argument; this comparison function should
|
||||
then call std::lexigraphical_compare(....). Example:
|
||||
|
||||
sub_range<string> sub = ...;
|
||||
if( sub == "foo" )
|
||||
|
||||
/*
|
||||
namespace range_detail
|
||||
{
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
|
||||
make_sub_range_impl( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
BOOST_ASSERT( advance_begin >= 0 );
|
||||
BOOST_ASSERT( advance_end >= 0 );
|
||||
|
||||
BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type
|
||||
new_begin = begin( r ),
|
||||
new_end = end( r );
|
||||
std::advance( new_begin, advance_begin );
|
||||
std::advance( new_end, -advance_end );
|
||||
return make_iterator_range( new_begin, new_end );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
|
||||
make_super_range_impl( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
BOOST_ASSERT( advance_begin >= 0 );
|
||||
BOOST_ASSERT( advance_end >= 0 );
|
||||
|
||||
BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type
|
||||
new_begin = begin( r ),
|
||||
new_end = end( r );
|
||||
std::advance( new_begin, -advance_begin );
|
||||
std::advance( new_end, advance_end );
|
||||
return make_iterator_range( new_begin, new_end );
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
/*
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
|
||||
make_sub_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end = 0 )
|
||||
{
|
||||
return range_detail::make_sub_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_result_iterator<Range>::type >
|
||||
make_super_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end = 0 )
|
||||
{
|
||||
return range_detail::make_super_range_impl( r, advance_begin, advance_end );
|
||||
}*/
|
||||
/*
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_sub_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end = 0 )
|
||||
{
|
||||
return range_detail::make_sub_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<Range>::type >
|
||||
make_sub_range( const Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end = 0 )
|
||||
{
|
||||
return range_detail::make_sub_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<Range>::type >
|
||||
make_super_range( Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end = 0 )
|
||||
{
|
||||
return range_detail::make_super_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
inline iterator_range< BOOST_DEDUCED_TYPENAME range_const_iterator<Range>::type >
|
||||
make_super_range( const Range& r,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end = 0 )
|
||||
{
|
||||
return range_detail::make_super_range_impl( r, advance_begin, advance_end );
|
||||
}*/
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
@ -71,18 +71,13 @@ void check_algorithm()
|
||||
typedef std::vector<int>::iterator iterator;
|
||||
std::pair<iterator,iterator> my_view( boost::begin( my_vector ),
|
||||
boost::begin( my_vector ) + N );
|
||||
char str_val[] = "a string";
|
||||
char* str = str_val;
|
||||
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( my_vector, 4, 2 ), 3u );
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( my_view, 4, 2 ), N );
|
||||
BOOST_CHECK_EQUAL( my_generic_replace( str, 'a', 'b' ), 0u );
|
||||
|
||||
}
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
|
@ -19,15 +19,10 @@
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
// This should be included before "using namespace boost",
|
||||
// otherwise gcc headers will be confused with boost::iterator
|
||||
// namespace.
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
@ -40,23 +35,23 @@ void check_array()
|
||||
|
||||
|
||||
// BOOST_RANGE_NO_STATIC_ASSERT
|
||||
#if !defined( __BORLANDC__ ) || ( _MSC_VER <= 1200 )
|
||||
#if !defined( __BORLANDC__ )
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<array_t>::type, int >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<array_t>::type, int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<array_t>::type, std::ptrdiff_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<array_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<array_t>::type, int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<array_t>::type, int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<const array_t>::type, const int >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<const array_t>::type, std::ptrdiff_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<const array_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const array_t>::type, const int* >::value ));
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_EQUAL( begin( my_array ), my_array );
|
||||
@ -69,9 +64,7 @@ void check_array()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
|
@ -1,73 +0,0 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
enum Container {};
|
||||
enum String {};
|
||||
|
||||
template< typename T >
|
||||
struct range_iterator;
|
||||
|
||||
template<>
|
||||
struct range_iterator<Container>
|
||||
{
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_iterator<String>
|
||||
{
|
||||
template< typename C >
|
||||
struct pts
|
||||
{
|
||||
typedef C type;
|
||||
};
|
||||
};
|
||||
|
||||
template< typename C >
|
||||
class iterator_of
|
||||
{
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::BOOST_NESTED_TEMPLATE pts<C>::type type;
|
||||
};
|
||||
|
||||
#include <vector>
|
||||
|
||||
void compat1()
|
||||
{
|
||||
std::vector<int> v;
|
||||
iterator_of< std::vector<int> >::type i = v.begin();
|
||||
}
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &compat1 ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,13 +17,10 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <string>
|
||||
|
||||
// This should be included before "using namespace boost",
|
||||
// otherwise gcc headers will be confused with boost::iterator
|
||||
// namespace.
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
@ -52,7 +49,7 @@ void check_const_ranges()
|
||||
|
||||
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
|
108
test/extension_mechanism.cpp
Executable file
108
test/extension_mechanism.cpp
Executable file
@ -0,0 +1,108 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# pragma warn -8091 // supress warning in Boost.Test
|
||||
# pragma warn -8057 // unused argument argc/argv in Boost.Test
|
||||
#endif
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <vector>
|
||||
|
||||
//
|
||||
// Generic range algorithm
|
||||
//
|
||||
template< class Rng >
|
||||
typename boost::range_iterator<Rng>::type foo_algo( Rng& r )
|
||||
{
|
||||
//
|
||||
// This will only compile for Rng = UDT if the qualified calls
|
||||
// find boost_range_XXX via ADL.
|
||||
//
|
||||
return boost::size(r) == 0u ? boost::begin(r) : boost::end(r);
|
||||
}
|
||||
|
||||
namespace Foo
|
||||
{
|
||||
//
|
||||
// Our sample UDT
|
||||
//
|
||||
struct X
|
||||
{
|
||||
typedef std::vector<int> data_t;
|
||||
typedef data_t::iterator iterator;
|
||||
typedef data_t::const_iterator const_iterator;
|
||||
typedef data_t::size_type size_type;
|
||||
|
||||
data_t vec;
|
||||
|
||||
void push_back( int i )
|
||||
{ vec.push_back(i); }
|
||||
};
|
||||
|
||||
//
|
||||
// The required functions. No type-traits need
|
||||
// to be defined because X defines the proper set of
|
||||
// nested types.
|
||||
//
|
||||
inline X::iterator range_begin( X& x )
|
||||
{
|
||||
return x.vec.begin();
|
||||
}
|
||||
|
||||
|
||||
inline X::const_iterator range_begin( const X& x )
|
||||
{
|
||||
return x.vec.begin();
|
||||
}
|
||||
|
||||
|
||||
inline X::iterator range_end( X& x )
|
||||
{
|
||||
return x.vec.end();
|
||||
}
|
||||
|
||||
inline X::const_iterator range_end( const X& x )
|
||||
{
|
||||
return x.vec.end();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void check_extension()
|
||||
{
|
||||
Foo::X x;
|
||||
x.push_back(3);
|
||||
const Foo::X x2;
|
||||
|
||||
foo_algo( x );
|
||||
foo_algo( x2 );
|
||||
}
|
||||
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &check_extension ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -19,12 +19,10 @@
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <vector>
|
||||
|
||||
using namespace boost;
|
||||
using boost::unit_test_framework::test_suite;
|
||||
|
||||
void check_iterator_pair()
|
||||
{
|
||||
@ -48,18 +46,20 @@ void check_iterator_pair()
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<pair_t>::type,
|
||||
detail::iterator_traits<pair_t::first_type>::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<pair_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<pair_t>::type, pair_t::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<pair_t>::type, pair_t::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<const_pair_tt>::type,
|
||||
detail::iterator_traits<const_pair_t::first_type>::value_type>::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
//
|
||||
// This behavior is not supported with v2.
|
||||
//BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<const_pair_tt>::type,
|
||||
detail::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<const_pair_tt>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
|
||||
|
||||
BOOST_CHECK( begin( pair ) == pair.first );
|
||||
BOOST_CHECK( end( pair ) == pair.second );
|
||||
@ -79,10 +79,8 @@ void check_iterator_pair()
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// Copyright Thorsten Ottosen & Larry Evans 2003-2005. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -8,6 +8,7 @@
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
//#include <boost/range/as_array.hpp>
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@ -18,27 +19,15 @@
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
// This should be included before "using namespace boost",
|
||||
// otherwise gcc headers will be confused with boost::iterator
|
||||
// namespace.
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
struct add_one
|
||||
{
|
||||
template< class T >
|
||||
T operator()( T r ) const
|
||||
{
|
||||
return r + 1;
|
||||
}
|
||||
};
|
||||
void check_reference_type();
|
||||
|
||||
void check_iterator_range()
|
||||
{
|
||||
@ -58,17 +47,17 @@ void check_iterator_range()
|
||||
BOOST_CHECK( !r.empty() );
|
||||
BOOST_CHECK( !r2.empty() );
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
if( !(bool)r )
|
||||
BOOST_CHECK( false );
|
||||
if( !(bool)r2 )
|
||||
BOOST_CHECK( false );
|
||||
#else
|
||||
//#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// if( !(bool)r )
|
||||
// BOOST_CHECK( false );
|
||||
// if( !(bool)r2 )
|
||||
// BOOST_CHECK( false );
|
||||
//#else
|
||||
if( !r )
|
||||
BOOST_CHECK( false );
|
||||
if( !r2 )
|
||||
BOOST_CHECK( false );
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
BOOST_CHECK_EQUAL( r.size(), size( r ) );
|
||||
BOOST_CHECK_EQUAL( r2.size(), size( r2 ) );
|
||||
@ -76,6 +65,12 @@ void check_iterator_range()
|
||||
BOOST_CHECK_EQUAL( distance( r.begin(), r.end() ),
|
||||
distance( begin( r2 ), end( r2 ) ) );
|
||||
cout << r << r2;
|
||||
|
||||
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
wcout << make_iterator_range( wstring( L"a wide string" ) )
|
||||
<< make_iterator_range( L"another wide string" );
|
||||
#endif
|
||||
|
||||
string res = copy_range<string>( r );
|
||||
BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) );
|
||||
@ -94,10 +89,22 @@ void check_iterator_range()
|
||||
BOOST_CHECK( rrr == rr );
|
||||
BOOST_CHECK( !( rrr != rr ) );
|
||||
BOOST_CHECK( !( rrr < rr ) );
|
||||
|
||||
const irange cr = make_iterator_range( str );
|
||||
BOOST_CHECK_EQUAL( cr.front(), 'h' );
|
||||
BOOST_CHECK_EQUAL( cr.back(), 'd' );
|
||||
BOOST_CHECK_EQUAL( cr[1], 'e' );
|
||||
|
||||
rrr = make_iterator_range( str, 1, -1 );
|
||||
BOOST_CHECK( rrr == "ello worl" );
|
||||
rrr = make_iterator_range( rrr, -1, 1 );
|
||||
BOOST_CHECK( rrr == str );
|
||||
|
||||
check_reference_type();
|
||||
}
|
||||
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
@ -109,6 +116,33 @@ test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// Check that constness is propgated correct from
|
||||
// the iterator types.
|
||||
//
|
||||
// Test contributed by Larry Evans.
|
||||
//
|
||||
|
||||
template< class Container >
|
||||
int test_iter_range( Container& a_cont )
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type citer_type;
|
||||
typedef iterator_range<citer_type> riter_type;
|
||||
riter_type a_riter( make_iterator_range( a_cont ) );
|
||||
a_riter.front();
|
||||
a_riter.back();
|
||||
int i = a_riter[0];
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void check_reference_type()
|
||||
{
|
||||
typedef vector<int> veci_type;
|
||||
veci_type a_vec;
|
||||
a_vec.push_back( 999 );
|
||||
test_iter_range<veci_type>(a_vec);
|
||||
test_iter_range<veci_type const>(a_vec);
|
||||
}
|
||||
|
86
test/mfc.cpp
Executable file
86
test/mfc.cpp
Executable file
@ -0,0 +1,86 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
#define _MSL_USING_NAMESPACE 1
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# pragma warn -8091 // supress warning in Boost.Test
|
||||
# pragma warn -8057 // unused argument argc/argv in Boost.Test
|
||||
#endif
|
||||
|
||||
#define BOOST_RANGE_ENABLE_MFC
|
||||
#define BOOST_RANGE_ENABLE_MCF_CARRAY
|
||||
|
||||
/*
|
||||
#define WIN32
|
||||
#define _WINDOWS
|
||||
#define _MBCS
|
||||
#define _AFXDLL
|
||||
#define _ATL_DLL
|
||||
*/
|
||||
|
||||
///Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_MBCS" /D "_AFXDLL" /D "_ATL_DLL" /Gm /EHsc /RTC1
|
||||
// /MDd /Zc:wchar_t /Yu"stdafx.h" /Fp"Debug/Foo.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /ZI /TP
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/range/detail/mfc/carray.hpp>
|
||||
#include <boost/range/detail/mfc/cstring.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
|
||||
void check_mfc()
|
||||
{
|
||||
CString s = "hello world";
|
||||
BOOST_CHECK( boost::begin( s ) + boost::size( s ) == boost::end( s ) );
|
||||
BOOST_CHECK( boost::size( s ) == boost::size( "hello world" ) );
|
||||
BOOST_CHECK( !boost::empty( s ) );
|
||||
const CString cs( s );
|
||||
BOOST_CHECK( boost::begin( cs ) + boost::size( cs ) == boost::end( cs ) );
|
||||
BOOST_CHECK( boost::size( cs ) == boost::size( "hello world" ) );
|
||||
BOOST_CHECK( !boost::empty( cs ) );
|
||||
|
||||
CArray<int,int> a;
|
||||
BOOST_CHECK( boost::empty( a ) );
|
||||
a.Add( 5 );
|
||||
a.Add( 10 );
|
||||
BOOST_CHECK( boost::begin( a ) + boost::size( a ) == boost::end( a ) );
|
||||
BOOST_CHECK( boost::size( a ) == 2 );
|
||||
BOOST_CHECK( !boost::empty( a ) );
|
||||
const CArray<int,int>& ca = a;
|
||||
BOOST_CHECK( boost::begin( ca ) + boost::size( ca ) == boost::end( ca ) );
|
||||
BOOST_CHECK( boost::size( ca ) == 2 );
|
||||
BOOST_CHECK( !boost::empty( ca ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &check_mfc ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,23 +17,19 @@
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
//#define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 1
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/size.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/detail/sfinae.hpp>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@ -91,10 +87,16 @@ void check_partial_workaround()
|
||||
|
||||
}
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
void check_partial_workaround()
|
||||
{
|
||||
}
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
#endif
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
@ -104,10 +106,3 @@ test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
int main() { return 0; }
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
@ -32,7 +32,7 @@ using namespace std;
|
||||
|
||||
void check_iterator()
|
||||
{
|
||||
typedef vector<char> vec_t;
|
||||
typedef vector<int> vec_t;
|
||||
typedef vec_t::iterator iterator;
|
||||
typedef pair<iterator,iterator> pair_t;
|
||||
typedef range_reverse_iterator<pair_t>::type rev_iterator;
|
||||
@ -41,15 +41,8 @@ void check_iterator()
|
||||
vec_t vec;
|
||||
pair_t p = make_pair( vec.begin(), vec.end() );
|
||||
rev_pair_t rp = make_pair( rbegin( p ), rend( p ) );
|
||||
char* str = "mutable";
|
||||
const char* cstr = "not mutable";
|
||||
char a[] = "mutable";
|
||||
const char ca[] = "not mutable";
|
||||
wchar_t* wstr = L"mutable";
|
||||
const wchar_t* cwstr= L"not mutable";
|
||||
wchar_t wa[] = L"mutable";
|
||||
const wchar_t cwa[]= L"not mutable";
|
||||
|
||||
int a[] = {1,2,3,4,5,6,7,8,9,10};
|
||||
const int ca[] = {1,2,3,4,5,6,7,8,9,10,11,12};
|
||||
BOOST_CHECK( rbegin( vec ) == range_reverse_iterator<vec_t>::type( vec.end() ) );
|
||||
BOOST_CHECK( rend( vec ) == range_reverse_iterator<vec_t>::type( vec.begin() ) );
|
||||
BOOST_CHECK( std::distance( rbegin( vec ), rend( vec ) ) == std::distance( begin( vec ), end( vec ) ) );
|
||||
@ -59,33 +52,15 @@ void check_iterator()
|
||||
BOOST_CHECK( std::distance( rbegin( p ), rend( p ) ) == std::distance( begin( rp ), end( rp ) ) );
|
||||
BOOST_CHECK( std::distance( begin( p ), end( p ) ) == std::distance( rbegin( rp ), rend( rp ) ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( &*begin( str ), &*( rend( str ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( str ) - 1 ), &*rbegin( str ) );
|
||||
BOOST_CHECK_EQUAL( &*begin( cstr ), &*( rend( cstr ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( cstr ) - 1 ), &*rbegin( cstr ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( &*begin( a ), &*( rend( a ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( a ) - 1 ), &*rbegin( a ) );
|
||||
BOOST_CHECK_EQUAL( &*begin( ca ), &*( rend( ca ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( ca ) - 1 ), &*rbegin( ca ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( &*begin( wstr ), &*( rend( wstr ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( wstr ) - 1 ), &*rbegin( wstr ) );
|
||||
BOOST_CHECK_EQUAL( &*begin( cwstr ), &*( rend( cwstr ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( cwstr ) - 1 ), &*rbegin( cwstr ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( &*begin( wa ), &*( rend( wa ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( wa ) - 1 ), &*rbegin( wa ) );
|
||||
BOOST_CHECK_EQUAL( &*begin( cwa ), &*( rend( cwa ) - 1 ) );
|
||||
BOOST_CHECK_EQUAL( &*( end( cwa ) - 1 ), &*rbegin( cwa ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Boost.Range library
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version
|
||||
@ -25,7 +25,6 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace boost;
|
||||
using boost::unit_test_framework::test_suite;
|
||||
|
||||
void check_std_container()
|
||||
{
|
||||
@ -36,15 +35,13 @@ void check_std_container()
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<vec_t>::type, vec_t::value_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<vec_t>::type, vec_t::const_iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<vec_t>::type, vec_t::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<vec_t>::type, vec_t::size_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<vec_t>::type, vec_t::iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<vec_t>::type, vec_t::iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<const vec_t>::type, vec_t::value_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const vec_t>::type, vec_t::iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const vec_t>::type, vec_t::const_iterator >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<const vec_t>::type, vec_t::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<const vec_t>::type, vec_t::size_type >::value ));
|
||||
|
||||
@ -61,11 +58,8 @@ void check_std_container()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
|
153
test/string.cpp
153
test/string.cpp
@ -8,6 +8,7 @@
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
|
||||
//#define _MSL_USING_NAMESPACE 1
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@ -16,31 +17,81 @@
|
||||
# pragma warn -8057 // unused argument argc/argv in Boost.Test
|
||||
#endif
|
||||
|
||||
#include <boost/range/as_array.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<T>::type
|
||||
str_begin( T& r )
|
||||
{
|
||||
return boost::begin( as_literal(r) );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<T>::type
|
||||
str_end( T& r )
|
||||
{
|
||||
return boost::end( as_literal(r) );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME boost::range_size<T>::type
|
||||
str_size( const T& r )
|
||||
{
|
||||
return boost::size( as_literal(r) );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline bool
|
||||
str_empty( T& r )
|
||||
{
|
||||
return boost::empty( as_literal(r) );
|
||||
}
|
||||
|
||||
template< typename Container, typename T >
|
||||
BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type
|
||||
find( Container& c, T value )
|
||||
{
|
||||
return std::find( boost::begin( c ), boost::end( c ), value );
|
||||
return std::find( str_begin(c), str_end(c),
|
||||
value );
|
||||
}
|
||||
|
||||
template< typename Container, typename T >
|
||||
BOOST_DEDUCED_TYPENAME boost::range_const_iterator<Container>::type
|
||||
BOOST_DEDUCED_TYPENAME boost::range_iterator<const Container>::type
|
||||
find( const Container& c, T value )
|
||||
{
|
||||
return std::find( boost::begin( c ), boost::end( c ), value );
|
||||
return std::find( str_begin(c), str_end(c),
|
||||
value );
|
||||
}
|
||||
|
||||
template< typename Container, typename T >
|
||||
BOOST_DEDUCED_TYPENAME boost::range_iterator<Container>::type
|
||||
find_mutable( Container& c, T value )
|
||||
{
|
||||
str_size( c );
|
||||
return std::find( str_begin(c), str_end(c),
|
||||
value );
|
||||
}
|
||||
|
||||
template< typename Container, typename T >
|
||||
BOOST_DEDUCED_TYPENAME boost::range_iterator<const Container>::type
|
||||
find_const( const Container& c, T value )
|
||||
{
|
||||
str_size( c );
|
||||
return std::find( str_begin(c), str_end(c),
|
||||
value );
|
||||
}
|
||||
|
||||
|
||||
std::vector<char>
|
||||
check_rvalue_return()
|
||||
{
|
||||
@ -54,57 +105,66 @@ void check_char()
|
||||
{
|
||||
typedef char* char_iterator_t;
|
||||
typedef char char_array_t[10];
|
||||
const char* char_s = "a string";
|
||||
char my_string[] = "another string";
|
||||
const unsigned my_string_length = 14;
|
||||
char* char_s2 = "a string";
|
||||
const char* char_s = "a string";
|
||||
char my_string[] = "another string";
|
||||
const char my_const_string[] = "another string";
|
||||
const unsigned my_string_length = 14;
|
||||
char* char_s2 = "a string";
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<char_iterator_t>::type,
|
||||
detail::iterator_traits<char_iterator_t>::value_type>::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_iterator_t>::type, char_iterator_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<char_iterator_t>::type, const char* >::value ));
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<char_iterator_t>::type,
|
||||
::std::ptrdiff_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<char_iterator_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<char_iterator_t>::type, char_iterator_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const char*>::type, const char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_iterator_t>::type, char_iterator_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const char*>::type, const char* >::value ));
|
||||
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<char_array_t>::type,
|
||||
char>::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_array_t>::type, char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<char_array_t>::type, const char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const char_array_t>::type, const char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<char_array_t>::type,
|
||||
::std::ptrdiff_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<char_array_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<char_array_t>::type, char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const char_array_t>::type, const char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<char_array_t>::type, char* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const char_array_t>::type, const char* >::value ));
|
||||
|
||||
BOOST_CHECK_EQUAL( begin( char_s ), char_s );
|
||||
std::size_t sz = size( char_s );
|
||||
const char* end1 = begin( char_s ) + sz;
|
||||
BOOST_CHECK_EQUAL( end( char_s ), end1 );
|
||||
BOOST_CHECK_EQUAL( empty( char_s ), (char_s == 0 || char_s[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( str_begin( char_s ), char_s );
|
||||
std::size_t sz = str_size(char_s);
|
||||
const char* str_end1 = str_begin( char_s ) + sz;
|
||||
BOOST_CHECK_EQUAL( str_end( char_s ), str_end1 );
|
||||
BOOST_CHECK_EQUAL( str_empty( char_s ), (char_s == 0 || char_s[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( sz, std::char_traits<char>::length( char_s ) );
|
||||
/*
|
||||
BOOST_CHECK_EQUAL( begin( char_s2 ), char_s2 );
|
||||
BOOST_CHECK_EQUAL( str_begin( char_s2 ), char_s2 );
|
||||
std::size_t sz2 = size( char_s2 );
|
||||
const char* end12 = begin( char_s2 ) + sz;
|
||||
BOOST_CHECK_EQUAL( end( char_s2 ), end12 );
|
||||
const char* str_end12 = str_begin( char_s2 ) + sz;
|
||||
BOOST_CHECK_EQUAL( str_end( char_s2 ), str_end12 );
|
||||
BOOST_CHECK_EQUAL( empty( char_s2 ), (char_s2 == 0 || char_s2[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( sz2, std::char_traits<char>::length( char_s2 ) );
|
||||
*/
|
||||
BOOST_CHECK_EQUAL( begin( my_string ), my_string );
|
||||
range_iterator<char_array_t>::type end2 = begin( my_string ) + size( my_string );
|
||||
range_iterator<char_array_t>::type end3 = end( my_string );
|
||||
BOOST_CHECK_EQUAL( end3, end2 );
|
||||
BOOST_CHECK_EQUAL( empty( my_string ), (my_string == 0 || my_string[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( size( my_string ), my_string_length );
|
||||
BOOST_CHECK_EQUAL( size( my_string ), std::char_traits<char>::length( my_string ) );
|
||||
BOOST_CHECK_EQUAL( str_begin( my_string ), my_string );
|
||||
range_iterator<char_array_t>::type str_end2 = str_begin( my_string ) + str_size(my_string);
|
||||
range_iterator<char_array_t>::type str_end3 = str_end(my_string);
|
||||
BOOST_CHECK_EQUAL( str_end3, str_end2 );
|
||||
BOOST_CHECK_EQUAL( str_empty( my_string ), (my_string == 0 || my_string[0] == char()) );
|
||||
BOOST_CHECK_EQUAL( str_size( my_string ), my_string_length );
|
||||
BOOST_CHECK_EQUAL( str_size( my_string ), std::char_traits<char>::length( my_string ) );
|
||||
|
||||
char to_search = 'n';
|
||||
BOOST_CHECK( find( char_s, to_search ) != end( char_s ) );
|
||||
BOOST_CHECK( find( my_string, to_search ) != end( my_string ) );
|
||||
|
||||
BOOST_CHECK( find_mutable( char_s, to_search ) != str_end( char_s ) );
|
||||
BOOST_CHECK( find_const( char_s, to_search ) != str_end(char_s) );
|
||||
|
||||
BOOST_CHECK( find_mutable( my_string, to_search ) != str_end(my_string) );
|
||||
BOOST_CHECK( find_const( my_string, to_search ) != str_end(my_string) );
|
||||
|
||||
BOOST_CHECK( find_mutable( char_s2, to_search ) != str_end(char_s) );
|
||||
BOOST_CHECK( find_const( char_s2, to_search ) != str_end(char_s2) );
|
||||
|
||||
BOOST_CHECK( find_const( as_array( my_string ), to_search ) != str_end(my_string) );
|
||||
BOOST_CHECK( find_const( as_array( my_const_string ), to_search ) != str_end(my_string) );
|
||||
}
|
||||
|
||||
|
||||
@ -125,31 +185,31 @@ void check_string()
|
||||
BOOST_STATIC_ASSERT(( is_same< range_value<wchar_iterator_t>::type,
|
||||
detail::iterator_traits<wchar_iterator_t>::value_type>::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<wchar_iterator_t>::type, wchar_iterator_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_const_iterator<wchar_iterator_t>::type, const wchar_t* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const wchar_t*>::type, const wchar_t* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_difference<wchar_iterator_t>::type,
|
||||
detail::iterator_traits<wchar_iterator_t>::difference_type >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_size<wchar_iterator_t>::type, std::size_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<wchar_iterator_t>::type, wchar_iterator_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_result_iterator<const wchar_t*>::type, const wchar_t* >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<wchar_iterator_t>::type, wchar_iterator_t >::value ));
|
||||
BOOST_STATIC_ASSERT(( is_same< range_iterator<const wchar_t*>::type, const wchar_t* >::value ));
|
||||
|
||||
std::size_t sz = size( char_ws );
|
||||
BOOST_CHECK_EQUAL( begin( char_ws ), char_ws );
|
||||
BOOST_CHECK_EQUAL( end( char_ws ), (begin( char_ws ) + sz) );
|
||||
BOOST_CHECK_EQUAL( empty( char_ws ), (char_ws == 0 || char_ws[0] == wchar_t()) );
|
||||
std::size_t sz = str_size( char_ws );
|
||||
BOOST_CHECK_EQUAL( str_begin( char_ws ), char_ws );
|
||||
BOOST_CHECK_EQUAL( str_end(char_ws), (str_begin( char_ws ) + sz) );
|
||||
BOOST_CHECK_EQUAL( str_empty( char_ws ), (char_ws == 0 || char_ws[0] == wchar_t()) );
|
||||
BOOST_CHECK_EQUAL( sz, std::char_traits<wchar_t>::length( char_ws ) );
|
||||
/*
|
||||
std::size_t sz2 = size( char_ws2 );
|
||||
BOOST_CHECK_EQUAL( begin( char_ws2 ), char_ws2 );
|
||||
BOOST_CHECK_EQUAL( end( char_ws2 ), (begin( char_ws2 ) + sz2) );
|
||||
BOOST_CHECK_EQUAL( str_begin( char_ws2 ), char_ws2 );
|
||||
BOOST_CHECK_EQUAL( str_end( char_ws2 ), (begin( char_ws2 ) + sz2) );
|
||||
BOOST_CHECK_EQUAL( empty( char_ws2 ), (char_ws2 == 0 || char_ws2[0] == wchar_t()) );
|
||||
BOOST_CHECK_EQUAL( sz2, std::char_traits<wchar_t>::length( char_ws2 ) );
|
||||
*/
|
||||
wchar_t to_search = L'n';
|
||||
BOOST_CHECK( find( char_ws, to_search ) != end( char_ws ) );
|
||||
BOOST_CHECK( find( char_ws, to_search ) != str_end(char_ws) );
|
||||
|
||||
#if BOOST_WORKAROUND(_MSC_VER, BOOST_TESTED_AT(1300))
|
||||
|
||||
BOOST_CHECK( find( my_wstring, to_search ) != end( my_wstring ) );
|
||||
BOOST_CHECK( find( my_wstring, to_search ) != str_end(my_wstring) );
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -158,13 +218,10 @@ void check_string()
|
||||
|
||||
}
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
|
||||
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
|
@ -16,35 +16,18 @@
|
||||
# pragma warn -8057 // unused argument argc/argv in Boost.Test
|
||||
#endif
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/sub_range.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// This should be included before "using namespace boost",
|
||||
// otherwise gcc headers will be confused with boost::iterator
|
||||
// namespace.
|
||||
#include <boost/test/included/unit_test_framework.hpp>
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
|
||||
struct add_one
|
||||
void check_sub_range()
|
||||
{
|
||||
template< class T >
|
||||
T operator()( T r ) const
|
||||
{
|
||||
return r + 1;
|
||||
}
|
||||
};
|
||||
|
||||
void check_iterator_range()
|
||||
{
|
||||
|
||||
|
||||
|
||||
typedef string::iterator iterator;
|
||||
typedef string::const_iterator const_iterator;
|
||||
typedef iterator_range<iterator> irange;
|
||||
@ -78,16 +61,16 @@ void check_iterator_range()
|
||||
BOOST_CHECK_EQUAL( r.size(), s.size() );
|
||||
BOOST_CHECK_EQUAL( r2.size(), s2.size() );
|
||||
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
if( !(bool)r )
|
||||
BOOST_CHECK( false );
|
||||
if( !(bool)r2 )
|
||||
BOOST_CHECK( false );
|
||||
if( !(bool)s )
|
||||
BOOST_CHECK( false );
|
||||
if( !(bool)s2 )
|
||||
BOOST_CHECK( false );
|
||||
#else
|
||||
//#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
// if( !(bool)r )
|
||||
// BOOST_CHECK( false );
|
||||
// if( !(bool)r2 )
|
||||
// BOOST_CHECK( false );
|
||||
// if( !(bool)s )
|
||||
// BOOST_CHECK( false );
|
||||
// if( !(bool)s2 )
|
||||
// BOOST_CHECK( false );
|
||||
//#else
|
||||
if( !r )
|
||||
BOOST_CHECK( false );
|
||||
if( !r2 )
|
||||
@ -96,33 +79,32 @@ void check_iterator_range()
|
||||
BOOST_CHECK( false );
|
||||
if( !s2 )
|
||||
BOOST_CHECK( false );
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
cout << r << r2 << s << s2;
|
||||
|
||||
string res = copy_range<string>( r );
|
||||
BOOST_CHECK( equal( res.begin(), res.end(), r.begin() ) );
|
||||
|
||||
typedef vector<char> string_type;
|
||||
string_type res2 = transform_range<string_type>( r, add_one() );
|
||||
BOOST_CHECK( res2[0] == 'i' );
|
||||
BOOST_CHECK( *res2.rbegin() == 'e' );
|
||||
|
||||
r.empty();
|
||||
s.empty();
|
||||
r.size();
|
||||
s.size();
|
||||
|
||||
irange singular_irange;
|
||||
BOOST_CHECK( singular_irange.empty() );
|
||||
BOOST_CHECK( singular_irange.size() == 0 );
|
||||
|
||||
srange singular_srange;
|
||||
BOOST_CHECK( singular_srange.empty() );
|
||||
BOOST_CHECK( singular_srange.size() == 0 );
|
||||
|
||||
BOOST_CHECK( empty( singular_irange ) );
|
||||
BOOST_CHECK( empty( singular_srange ) );
|
||||
//
|
||||
// As of range v2 not legal anymore.
|
||||
//
|
||||
//irange singular_irange;
|
||||
//BOOST_CHECK( singular_irange.empty() );
|
||||
//BOOST_CHECK( singular_irange.size() == 0 );
|
||||
//
|
||||
//srange singular_srange;
|
||||
//BOOST_CHECK( singular_srange.empty() );
|
||||
//BOOST_CHECK( singular_srange.size() == 0 );
|
||||
//
|
||||
//BOOST_CHECK( empty( singular_irange ) );
|
||||
//BOOST_CHECK( empty( singular_srange ) );
|
||||
//
|
||||
|
||||
srange rr = make_iterator_range( str );
|
||||
BOOST_CHECK( rr.equal( r ) );
|
||||
@ -139,16 +121,30 @@ void check_iterator_range()
|
||||
BOOST_CHECK( rrr == rr );
|
||||
BOOST_CHECK( !( rrr != rr ) );
|
||||
BOOST_CHECK( !( rrr < rr ) );
|
||||
}
|
||||
|
||||
const irange cr = make_iterator_range( str );
|
||||
BOOST_CHECK_EQUAL( cr.front(), 'h' );
|
||||
BOOST_CHECK_EQUAL( cr.back(), 'd' );
|
||||
BOOST_CHECK_EQUAL( cr[1], 'e' );
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
rrr = make_iterator_range( str, 1, -1 );
|
||||
BOOST_CHECK( rrr == "ello worl" );
|
||||
rrr = make_iterator_range( rrr, -1, 1 );
|
||||
BOOST_CHECK( rrr == str );
|
||||
rrr.front() = 'H';
|
||||
rrr.back() = 'D';
|
||||
rrr[1] = 'E';
|
||||
BOOST_CHECK( rrr == "HEllo worlD" );
|
||||
}
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
|
||||
test->add( BOOST_TEST_CASE( &check_iterator_range ) );
|
||||
test->add( BOOST_TEST_CASE( &check_sub_range ) );
|
||||
|
||||
return test;
|
||||
}
|
||||
|
Reference in New Issue
Block a user