forked from boostorg/range
Compare commits
27 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
9cf3355526 | |||
68a63cab85 | |||
06c54ccd48 | |||
2e298b5e60 | |||
00e70244a5 | |||
3f98d69c94 | |||
4767db522b | |||
f6e555dda3 | |||
01826978d6 | |||
336c12b60f | |||
82768af3d2 | |||
8984de1c74 | |||
4db083cd6d | |||
f4cde208f2 | |||
d130dff5ec | |||
aa9158b199 | |||
bbd9fdb7bd | |||
17514e1d44 | |||
d759c23552 | |||
cf9ad808a6 | |||
028bff0c22 | |||
33a8016af3 | |||
24466ae189 | |||
c8ffe55ae5 | |||
a862a573df | |||
0b0dfc0e06 | |||
e0a76af0f9 |
22
doc/Jamfile.v2
Normal file
22
doc/Jamfile.v2
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
use-project boost : $(BOOST_ROOT) ;
|
||||
|
||||
|
||||
import boostbook : boostbook ;
|
||||
import quickbook ;
|
||||
|
||||
xml boost_range : boost_range.qbk ;
|
||||
|
||||
boostbook standalone
|
||||
:
|
||||
boost_range
|
||||
:
|
||||
<xsl:param>toc.max.depth=2
|
||||
<xsl:param>toc.section.depth=4
|
||||
<xsl:param>chunk.section.depth=2
|
||||
|
||||
# <xsl:param>generate.section.toc.level=4
|
||||
# <xsl:param>chunk.first.sections=7
|
||||
# <xsl:param>toc.section.depth=10
|
||||
;
|
||||
|
1208
doc/boost_range.html
1208
doc/boost_range.html
File diff suppressed because it is too large
Load Diff
1234
doc/boost_range.qbk
Normal file
1234
doc/boost_range.qbk
Normal file
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,12 @@
|
||||
<td ><a href="boost_range.html#range_iterator"
|
||||
>range_iterator</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/mutable_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_mutable_iterator"
|
||||
>range_mutable_iterator</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/const_iterator.hpp></code></td>
|
||||
@ -67,27 +73,24 @@
|
||||
<td ><a href="boost_range.html#range_size" >range_size</a></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/result_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_result_iterator"
|
||||
>range_result_iterator</a></td>
|
||||
<tr >
|
||||
<td ><code ><boost/range/pointer.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_pointer"
|
||||
>range_pointer</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/category.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_category"
|
||||
>range_category</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
|
||||
<tr >
|
||||
<td ><code ><boost/range/reverse_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_reverse_iterator" >range_reverse_iterator</a></td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/const_reverse_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_const_reverse_iterator" >range_const_reverse_iterator</a></td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/reverse_result_iterator.hpp></code></td>
|
||||
<td ><a href="boost_range.html#range_reverse_result_iterator">range_reverse_result_iterator</a></td>
|
||||
<td>- </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/begin.hpp></code></td>
|
||||
<td >
|
||||
@ -108,11 +111,17 @@
|
||||
<td ><code ><boost/range/empty.hpp></code></td>
|
||||
<td ><a href="boost_range.html#empty" >empty</a></td>
|
||||
<td><a href="range.html#single_pass_range">Single Pass Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/distance.hpp></code></td>
|
||||
<td ><a href="boost_range.html#distance" >distance</a></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/size.hpp></code></td>
|
||||
<td ><a href="boost_range.html#size" >size</a></td>
|
||||
<td><a href="range.html#forward_range">Forward Range</a> </td>
|
||||
<td><a href="range.html#random_access_range">Random Access Range</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/rbegin.hpp></code></td>
|
||||
@ -130,6 +139,21 @@
|
||||
</td>
|
||||
<td><a href="range.html#bidirectional_range">Bidirectional Range</a> </td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/as_array.hpp></code></td>
|
||||
<td >
|
||||
<a href="boost_range.html#as_array" >as_array</a>
|
||||
</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<td ><code ><boost/range/as_literal.hpp></code></td>
|
||||
<td >
|
||||
<a href="boost_range.html#as_literal" >as_literal</a>
|
||||
</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
|
||||
<tr >
|
||||
<td ><code ><boost/range/iterator_range.hpp></code></td>
|
||||
<td ><a href="utility_class.html#iter_range"
|
||||
|
@ -60,22 +60,14 @@ free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
more flexible, compact and maintainable client code
|
||||
</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>
|
||||
safe use of built-in arrays
|
||||
</li>
|
||||
<li >
|
||||
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>
|
||||
):
|
||||
<blockquote>
|
||||
Below are given a small example (the complete example can be found <a
|
||||
href="../test/algorithm_example.cpp" target="_self" >here</a>): <blockquote>
|
||||
<pre >
|
||||
<span class=comment>
|
||||
//
|
||||
@ -89,7 +81,7 @@ free-standing functions so syntactic and/or semantic differences can be removed.
|
||||
</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
|
||||
</span><span class=keyword>inline </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=keyword>const </span><span
|
||||
class=identifier>ForwardReadableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
</span><span class=identifier>find</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>ForwardReadableRange</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=special>{
|
||||
@ -100,7 +92,7 @@ class=identifier>ForwardReadableRange </span><span class=special>>::</span><s
|
||||
// replace first value and return its index
|
||||
//
|
||||
</span><span class=keyword>template</span><span class=special>< </span><span class=keyword>class </span><span class=identifier>ForwardReadableWriteableRange</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_size</span><span class=special>< </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
</span><span class=keyword>inline </span><span class=keyword>typename </span><span class=identifier>boost</span><span class=special>::</span><span class=identifier>range_difference</span><span class=special>< </span><span class=identifier>ForwardReadableWriteableRange </span><span class=special>>::</span><span class=identifier>type
|
||||
</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>);
|
||||
@ -146,7 +138,7 @@ Notice that we have to
|
||||
|
||||
<hr>
|
||||
<p>
|
||||
(C) Copyright Thorsten Ottosen 2003-2004
|
||||
(C) Copyright Thorsten Ottosen 2003-2007
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
313
doc/mfc_atl.html
Normal file
313
doc/mfc_atl.html
Normal file
@ -0,0 +1,313 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
|
||||
<title>Boost Range MFC/ATL Extension</title>
|
||||
<meta name="author" content="Shunsuke Sogame" />
|
||||
<meta name="date" content="26th of May 2006" />
|
||||
<meta name="copyright" content="Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt)." />
|
||||
<style type="text/css">
|
||||
|
||||
@import "http://www.boost.org/libs/ptr_container/doc/default.css";
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="boost-range-mfc-atl-extension">
|
||||
<h1 class="title"><img alt="Boost" src="http://www.boost.org/libs/ptr_container/doc/boost.png" /> Range MFC/ATL Extension</h1>
|
||||
<table class="docinfo" frame="void" rules="none">
|
||||
<col class="docinfo-name" />
|
||||
<col class="docinfo-content" />
|
||||
<tbody valign="top">
|
||||
<tr><th class="docinfo-name">Author:</th>
|
||||
<td>Shunsuke Sogame</td></tr>
|
||||
<tr><th class="docinfo-name">Contact:</th>
|
||||
<td><a class="first last reference" href="mailto:mb2act@yahoo.co.jp">mb2act@yahoo.co.jp</a></td></tr>
|
||||
<tr><th class="docinfo-name">Date:</th>
|
||||
<td>26th of May 2006</td></tr>
|
||||
<tr><th class="docinfo-name">Copyright:</th>
|
||||
<td>Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see <a class="reference" href="http://www.boost.org/LICENSE_1_0.txt">LICENSE_1_0.txt</a>).</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="section">
|
||||
<h1><a id="overview" name="overview">Overview</a></h1>
|
||||
<p>Boost.Range MFC/ATL Extension provides <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> support for MFC/ATL collection and string types.</p>
|
||||
<pre class="literal-block">
|
||||
CTypedPtrArray<CPtrArray, CList<CString> *> myArray;
|
||||
...
|
||||
BOOST_FOREACH (CList<CString> *theList, myArray)
|
||||
{
|
||||
BOOST_FOREACH (CString& str, *theList)
|
||||
{
|
||||
boost::to_upper(str);
|
||||
std::sort(boost::begin(str), boost::end(str));
|
||||
...
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="#requirements">Requirements</a></li>
|
||||
<li><a class="reference" href="#mfc-ranges">MFC Ranges</a></li>
|
||||
<li><a class="reference" href="#atl-ranges">ATL Ranges</a></li>
|
||||
<li><a class="reference" href="#const-ranges">const Ranges</a></li>
|
||||
<li><a class="reference" href="#references">References</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="requirements" name="requirements">Requirements</a></h1>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="http://www.boost.org/">Boost C++ Libraries Version 1.34.0</a> or later (no compilation required)</li>
|
||||
<li>Visual C++ 7.1 or Visual C++ 8.0</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="mfc-ranges" name="mfc-ranges">MFC Ranges</a></h1>
|
||||
<p>If the <tt class="docutils literal"><span class="pre"><boost/range/mfc.hpp></span></tt> is included before or after <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> headers,
|
||||
the MFC collections and strings become models of Range.
|
||||
The table below lists the Traversal Category and <tt class="docutils literal"><span class="pre">range_reference</span></tt> of MFC ranges.</p>
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="34%" />
|
||||
<col width="21%" />
|
||||
<col width="45%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head"><tt class="docutils literal"><span class="pre">Range</span></tt></th>
|
||||
<th class="head">Traversal Category</th>
|
||||
<th class="head"><tt class="docutils literal"><span class="pre">range_reference<Range>::type</span></tt></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CArray<T,A></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">T&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CList<T,A></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">T&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMap<K,AK,M,AM></span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">Range::CPair&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CTypedPtrArray<B,T*></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">T*</span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CTypedPtrList<B,T*></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">T*</span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CTypedPtrMap<B,T*,V*></span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">std::pair<T*,V*></span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CByteArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">BYTE&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CDWordArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">DWORD&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CObArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">CObject*</span> <span class="pre">&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CPtrArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">void*</span> <span class="pre">&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CStringArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">CString&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CUIntArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">UINT&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CWordArray</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">WORD&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CObList</span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">CObject*</span> <span class="pre">&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CPtrList</span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">void*</span> <span class="pre">&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CStringList</span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">CString&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMapPtrToWord</span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">std::pair<void*,WORD></span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMapPtrToPtr</span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">std::pair<void*,void*></span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMapStringToOb</span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">std::pair<String,CObject*></span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMapStringToString</span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">Range::CPair&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMapWordToOb</span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">std::pair<WORD,CObject*></span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CMapWordToPtr</span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">std::pair<WORD,void*></span> <span class="pre">const</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Other <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> metafunctions are defined by the following.
|
||||
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference<Range>::type</span></tt>.
|
||||
<tt class="docutils literal"><span class="pre">range_value<Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">remove_reference<remove_const<Ref>::type>::type</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">range_difference<Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
|
||||
<tt class="docutils literal"><span class="pre">range_pointer<Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer<remove_reference<Ref>::type>::type</span></tt>.
|
||||
As for <tt class="docutils literal"><span class="pre">const</span> <span class="pre">Range</span></tt>, see <a class="reference" href="#const-ranges">const Ranges</a>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="atl-ranges" name="atl-ranges">ATL Ranges</a></h1>
|
||||
<p>If the <tt class="docutils literal"><span class="pre"><boost/range/atl.hpp></span></tt> is included before or after <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> headers,
|
||||
the ATL collections and strings become models of Range.
|
||||
The table below lists the Traversal Category and <tt class="docutils literal"><span class="pre">range_reference</span></tt> of ATL ranges.</p>
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="34%" />
|
||||
<col width="21%" />
|
||||
<col width="45%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head"><tt class="docutils literal"><span class="pre">Range</span></tt></th>
|
||||
<th class="head">Traversal Category</th>
|
||||
<th class="head"><tt class="docutils literal"><span class="pre">range_reference<Range>::type</span></tt></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign="top">
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CAtlArray<E,ET></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">E&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CAutoPtrArray<E></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">E&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CInterfaceArray<I,pi></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">CComQIPtr<I,pi>&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CAtlList<E,ET></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">E&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CAutoPtrList<E></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">E&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CHeapPtrList<E,A></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">E&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CInterfaceList<I,pi></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">CComQIPtr<I,pi>&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CAtlMap<K,V,KT,VT></span></tt></td>
|
||||
<td>Forward</td>
|
||||
<td><tt class="docutils literal"><span class="pre">Range::CPair&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CRBTree<K,V,KT,VT></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">Range::CPair&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CRBMap<K,V,KT,VT></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">Range::CPair&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CRBMultiMap<K,V,KT,VT></span></tt></td>
|
||||
<td>Bidirectional</td>
|
||||
<td><tt class="docutils literal"><span class="pre">Range::CPair&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CSimpleStringT<B,b></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">B&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CStringT<B,ST></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">B&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CFixedStringT<S,n></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">range_reference<S>::type</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CStringT<B,ST></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">B&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CComBSTR</span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">OLECHAR&</span></tt></td>
|
||||
</tr>
|
||||
<tr><td><tt class="docutils literal"><span class="pre">CSimpleArray<T,TE></span></tt></td>
|
||||
<td>Random Access</td>
|
||||
<td><tt class="docutils literal"><span class="pre">T&</span></tt></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Other <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> metafunctions are defined by the following.
|
||||
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference<Range>::type</span></tt>.
|
||||
<tt class="docutils literal"><span class="pre">range_value<Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">remove_reference<Ref>::type</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">range_difference<Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
|
||||
<tt class="docutils literal"><span class="pre">range_pointer<Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer<remove_reference<Ref>::type>::type</span></tt>.
|
||||
As for <tt class="docutils literal"><span class="pre">const</span> <span class="pre">Range</span></tt>, see <a class="reference" href="#const-ranges">const Ranges</a>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="const-ranges" name="const-ranges">const Ranges</a></h1>
|
||||
<p><tt class="docutils literal"><span class="pre">range_reference<const</span> <span class="pre">Range>::type</span></tt> is defined by the following algorithm.
|
||||
Let <tt class="docutils literal"><span class="pre">Range</span></tt> be any type listed above and <tt class="docutils literal"><span class="pre">ReF</span></tt> be the same as <tt class="docutils literal"><span class="pre">range_reference<Range>::type</span></tt>.</p>
|
||||
<pre class="literal-block">
|
||||
if (Range is CObArray || Range is CObList)
|
||||
return CObject const * &
|
||||
else if (Range is CPtrArray || Range is CPtrList)
|
||||
return void const * &
|
||||
else if (there is a type X such that X& is the same as ReF)
|
||||
return X const &
|
||||
else if (there is a type X such that X* const is the same as ReF)
|
||||
return X const * const
|
||||
else
|
||||
return ReF
|
||||
</pre>
|
||||
<p>Other <a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a> metafunctions are defined by the following.
|
||||
<tt class="docutils literal"><span class="pre">range_value<const</span> <span class="pre">Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">range_value<Range>::type</span></tt>,
|
||||
<tt class="docutils literal"><span class="pre">range_difference<const</span> <span class="pre">Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">std::ptrdiff_t</span></tt>, and
|
||||
<tt class="docutils literal"><span class="pre">range_pointer<const</span> <span class="pre">Range>::type</span></tt> is the same as <tt class="docutils literal"><span class="pre">add_pointer<remove_reference<range_reference<const</span> <span class="pre">Range>::type>::type>::type</span></tt>.</p>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h1><a id="references" name="references">References</a></h1>
|
||||
<ul class="simple">
|
||||
<li><a class="reference" href="http://www.boost.org/libs/range/">Boost.Range</a></li>
|
||||
<li><a class="reference" href="http://msdn2.microsoft.com/en-us/library/942860sh.aspx">MFC Collections</a></li>
|
||||
<li><a class="reference" href="http://msdn2.microsoft.com/en-US/library/15e672bd.aspx">ATL Collection Classes</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
<a class="reference" href="mfc_atl.rst">View document source</a>.
|
||||
Generated on: 2006-06-04 22:37 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
232
doc/mfc_atl.rst
Normal file
232
doc/mfc_atl.rst
Normal file
@ -0,0 +1,232 @@
|
||||
|
||||
++++++++++++++++++++++++++++++++
|
||||
|Boost| Range MFC/ATL Extension
|
||||
++++++++++++++++++++++++++++++++
|
||||
|
||||
.. |Boost| image:: http://www.boost.org/libs/ptr_container/doc/boost.png
|
||||
|
||||
|
||||
|
||||
:Author: Shunsuke Sogame
|
||||
:Contact: mb2act@yahoo.co.jp
|
||||
:date: 26th of May 2006
|
||||
:copyright: Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
|
||||
|
||||
__ http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
|
||||
|
||||
========
|
||||
Overview
|
||||
========
|
||||
|
||||
Boost.Range MFC/ATL Extension provides `Boost.Range`_ support for MFC/ATL collection and string types.
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
CTypedPtrArray<CPtrArray, CList<CString> \*> myArray;
|
||||
...
|
||||
BOOST_FOREACH (CList<CString> \*theList, myArray)
|
||||
{
|
||||
BOOST_FOREACH (CString& str, \*theList)
|
||||
{
|
||||
boost::to_upper(str);
|
||||
std::sort(boost::begin(str), boost::end(str));
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
* `Requirements`_
|
||||
* `MFC Ranges`_
|
||||
* `ATL Ranges`_
|
||||
* `const Ranges`_
|
||||
* `References`_
|
||||
|
||||
|
||||
|
||||
============
|
||||
Requirements
|
||||
============
|
||||
|
||||
- `Boost C++ Libraries Version 1.34.0`__ or later (no compilation required)
|
||||
- Visual C++ 7.1 or Visual C++ 8.0
|
||||
|
||||
__ Boost_
|
||||
|
||||
|
||||
|
||||
==========
|
||||
MFC Ranges
|
||||
==========
|
||||
|
||||
If the ``<boost/range/mfc.hpp>`` is included before or after `Boost.Range`_ headers,
|
||||
the MFC collections and strings become models of Range.
|
||||
The table below lists the Traversal Category and ``range_reference`` of MFC ranges.
|
||||
|
||||
|
||||
============================= ================== =======================================
|
||||
``Range`` Traversal Category ``range_reference<Range>::type``
|
||||
============================= ================== =======================================
|
||||
``CArray<T,A>`` Random Access ``T&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CList<T,A>`` Bidirectional ``T&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMap<K,AK,M,AM>`` Forward ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CTypedPtrArray<B,T*>`` Random Access ``T* const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CTypedPtrList<B,T*>`` Bidirectional ``T* const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CTypedPtrMap<B,T*,V*>`` Forward ``std::pair<T*,V*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CByteArray`` Random Access ``BYTE&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CDWordArray`` Random Access ``DWORD&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CObArray`` Random Access ``CObject* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CPtrArray`` Random Access ``void* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringArray`` Random Access ``CString&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CUIntArray`` Random Access ``UINT&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CWordArray`` Random Access ``WORD&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CObList`` Bidirectional ``CObject* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CPtrList`` Bidirectional ``void* &``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringList`` Bidirectional ``CString&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapPtrToWord`` Forward ``std::pair<void*,WORD> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapPtrToPtr`` Forward ``std::pair<void*,void*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapStringToOb`` Forward ``std::pair<String,CObject*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapStringToString`` Forward ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapWordToOb`` Forward ``std::pair<WORD,CObject*> const``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CMapWordToPtr`` Forward ``std::pair<WORD,void*> const``
|
||||
============================= ================== =======================================
|
||||
|
||||
|
||||
Other `Boost.Range`_ metafunctions are defined by the following.
|
||||
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
|
||||
``range_value<Range>::type`` is the same as ``remove_reference<remove_const<Ref>::type>::type``,
|
||||
``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
|
||||
``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
|
||||
As for ``const Range``, see `const Ranges`_.
|
||||
|
||||
|
||||
|
||||
==========
|
||||
ATL Ranges
|
||||
==========
|
||||
|
||||
If the ``<boost/range/atl.hpp>`` is included before or after `Boost.Range`_ headers,
|
||||
the ATL collections and strings become models of Range.
|
||||
The table below lists the Traversal Category and ``range_reference`` of ATL ranges.
|
||||
|
||||
|
||||
============================= ================== =======================================
|
||||
``Range`` Traversal Category ``range_reference<Range>::type``
|
||||
============================= ================== =======================================
|
||||
``CAtlArray<E,ET>`` Random Access ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAutoPtrArray<E>`` Random Access ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CInterfaceArray<I,pi>`` Random Access ``CComQIPtr<I,pi>&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAtlList<E,ET>`` Bidirectional ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAutoPtrList<E>`` Bidirectional ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CHeapPtrList<E,A>`` Bidirectional ``E&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CInterfaceList<I,pi>`` Bidirectional ``CComQIPtr<I,pi>&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CAtlMap<K,V,KT,VT>`` Forward ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CRBTree<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CRBMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CRBMultiMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CSimpleStringT<B,b>`` Random Access ``B&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringT<B,ST>`` Random Access ``B&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CFixedStringT<S,n>`` Random Access ``range_reference<S>::type``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CStringT<B,ST>`` Random Access ``B&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CComBSTR`` Random Access ``OLECHAR&``
|
||||
----------------------------- ------------------ ---------------------------------------
|
||||
``CSimpleArray<T,TE>`` Random Access ``T&``
|
||||
============================= ================== =======================================
|
||||
|
||||
|
||||
Other `Boost.Range`_ metafunctions are defined by the following.
|
||||
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
|
||||
``range_value<Range>::type`` is the same as ``remove_reference<Ref>::type``,
|
||||
``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
|
||||
``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
|
||||
As for ``const Range``, see `const Ranges`_.
|
||||
|
||||
|
||||
|
||||
============
|
||||
const Ranges
|
||||
============
|
||||
|
||||
``range_reference<const Range>::type`` is defined by the following algorithm.
|
||||
Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
if (Range is CObArray || Range is CObList)
|
||||
return CObject const \* &
|
||||
else if (Range is CPtrArray || Range is CPtrList)
|
||||
return void const \* &
|
||||
else if (there is a type X such that X& is the same as ReF)
|
||||
return X const &
|
||||
else if (there is a type X such that X* const is the same as ReF)
|
||||
return X const \* const
|
||||
else
|
||||
return ReF
|
||||
|
||||
|
||||
Other `Boost.Range`_ metafunctions are defined by the following.
|
||||
``range_value<const Range>::type`` is the same as ``range_value<Range>::type``,
|
||||
``range_difference<const Range>::type`` is the same as ``std::ptrdiff_t``, and
|
||||
``range_pointer<const Range>::type`` is the same as ``add_pointer<remove_reference<range_reference<const Range>::type>::type>::type``.
|
||||
|
||||
|
||||
|
||||
==========
|
||||
References
|
||||
==========
|
||||
- `Boost.Range`_
|
||||
- `MFC Collections`__
|
||||
- `ATL Collection Classes`__
|
||||
|
||||
__ http://msdn2.microsoft.com/en-us/library/942860sh.aspx
|
||||
__ http://msdn2.microsoft.com/en-US/library/15e672bd.aspx
|
||||
|
||||
|
||||
|
||||
.. _Boost C++ Libraries: http://www.boost.org/
|
||||
.. _Boost: `Boost C++ Libraries`_
|
||||
.. _Boost.Range: http://www.boost.org/libs/range/
|
||||
.. _forward: http://www.boost.org/libs/range/doc/range.html#forward_range
|
||||
.. _bidirectional: http://www.boost.org/libs/range/doc/range.html#forward_range
|
||||
.. _random access: http://www.boost.org/libs/range/doc/range.html#random_access_range
|
||||
|
@ -173,11 +173,11 @@ class=keyword>const;</span>
|
||||
</span><span class=identifier>ForwardTraversalIterator </span><span class=identifier>End </span><span class=special>);
|
||||
|
||||
</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>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>iterator_range</span><span class=special>< </span><span class=keyword>typename </span><span class=identifier>iterator</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=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>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>iterator_range</span><span class=special>< </span><span class=keyword>typename </span><span class=identifier>const_iterator</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>
|
||||
@ -305,7 +305,7 @@ class can propagate constness since it knows what a corresponding
|
||||
</span><span class=identifier>sub_range</span><span class=special>( </span><span class=identifier>ForwardRange2</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>ForwardRange2 </span><span class=special>>
|
||||
</span><span class=identifier>sub_range</span><span class=special>( </span><span class=keyword>const </span><span class=identifier>Range2</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
</span><span class=identifier>sub_range</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>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=identifier>ForwardRange2</span><span class=special>& </span><span class=identifier>r </span><span class=special>);
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/detail/str_types.hpp>
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
|
||||
@ -66,7 +69,7 @@ namespace boost
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline long is_char_ptr( T r )
|
||||
inline long is_char_ptr( T /* r */ )
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
@ -104,15 +107,23 @@ namespace boost
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<Char*> as_literal( Char (&arr)[sz] )
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
|
||||
return boost::make_iterator_range<Char*>( arr, arr + sz - 1 );
|
||||
#else
|
||||
return boost::make_iterator_range( arr, arr + sz - 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template< class Char, std::size_t sz >
|
||||
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
|
||||
inline iterator_range<const Char*> as_literal( const Char (&arr)[sz] )
|
||||
{
|
||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x590)) && __BORLANDC__ >= 0x590
|
||||
return boost::make_iterator_range<const Char*>( arr, arr + sz - 1 );
|
||||
#else
|
||||
return boost::make_iterator_range( arr, arr + sz - 1 );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
733
include/boost/range/atl.hpp
Normal file
733
include/boost/range/atl.hpp
Normal file
@ -0,0 +1,733 @@
|
||||
#ifndef BOOST_RANGE_ATL_HPP
|
||||
#define BOOST_RANGE_ATL_HPP
|
||||
|
||||
|
||||
|
||||
|
||||
// Boost.Range ATL Extension
|
||||
//
|
||||
// Copyright Shunsuke Sogame 2005-2006.
|
||||
// Distributed under 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)
|
||||
|
||||
|
||||
|
||||
|
||||
// config
|
||||
//
|
||||
|
||||
|
||||
#include <atldef.h> // _ATL_VER
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
#if (_ATL_VER < 0x0700)
|
||||
#define BOOST_RANGE_ATL_NO_COLLECTIONS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
#if (_ATL_VER < 0x0700) // dubious
|
||||
#define BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
|
||||
#if (_MSC_VER < 1310) // from <boost/regex/mfc.hpp>, but dubious
|
||||
#define BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// forward declarations
|
||||
//
|
||||
|
||||
|
||||
#include <basetyps.h> // IID
|
||||
|
||||
|
||||
namespace ATL {
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
template< class E, class ETraits >
|
||||
class CAtlArray;
|
||||
|
||||
template< class E >
|
||||
class CAutoPtrArray;
|
||||
|
||||
template< class I, const IID *piid >
|
||||
class CInterfaceArray;
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
template< class E, class ETraits >
|
||||
class CAtlList;
|
||||
|
||||
template< class E >
|
||||
class CAutoPtrList;
|
||||
|
||||
template< class E, class Allocator >
|
||||
class CHeapPtrList;
|
||||
|
||||
template< class I, const IID *piid >
|
||||
class CInterfaceList;
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
template< class K, class V, class KTraits, class VTraits >
|
||||
class CAtlMap;
|
||||
|
||||
template< class K, class V, class KTraits, class VTraits >
|
||||
class CRBTree;
|
||||
|
||||
template< class K, class V, class KTraits, class VTraits >
|
||||
class CRBMap;
|
||||
|
||||
template< class K, class V, class KTraits, class VTraits >
|
||||
class CRBMultiMap;
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
|
||||
template< class BaseType, bool t_bMFCDLL >
|
||||
class CSimpleStringT;
|
||||
#else
|
||||
template< class BaseType >
|
||||
class CSimpleStringT;
|
||||
#endif
|
||||
|
||||
template< class BaseType, class StringTraits >
|
||||
class CStringT;
|
||||
|
||||
template< class StringType, int t_nChars >
|
||||
class CFixedStringT;
|
||||
|
||||
template< class BaseType, const int t_nSize >
|
||||
class CStaticString;
|
||||
|
||||
|
||||
#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
|
||||
|
||||
// simples
|
||||
//
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
|
||||
template< class T, class TEqual >
|
||||
class CSimpleArray;
|
||||
|
||||
template< class TKey, class TVal, class TEqual >
|
||||
class CSimpleMap;
|
||||
|
||||
#else
|
||||
|
||||
template< class T >
|
||||
class CSimpleArray;
|
||||
|
||||
template< class T >
|
||||
class CSimpleValArray;
|
||||
|
||||
template< class TKey, class TVal >
|
||||
class CSimpleMap;
|
||||
|
||||
#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
|
||||
|
||||
// pointers
|
||||
//
|
||||
template< class E >
|
||||
class CAutoPtr;
|
||||
|
||||
template< class T >
|
||||
class CComPtr;
|
||||
|
||||
template< class T, const IID *piid >
|
||||
class CComQIPtr;
|
||||
|
||||
template< class E, class Allocator >
|
||||
class CHeapPtr;
|
||||
|
||||
template< class T >
|
||||
class CAdapt;
|
||||
|
||||
|
||||
} // namespace ATL
|
||||
|
||||
|
||||
|
||||
|
||||
// indirect_iterator customizations
|
||||
//
|
||||
|
||||
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/pointee.hpp>
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
|
||||
template< class E >
|
||||
struct pointee< ATL::CAutoPtr<E> > :
|
||||
mpl::identity<E>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct pointee< ATL::CComPtr<T> > :
|
||||
mpl::identity<T>
|
||||
{ };
|
||||
|
||||
template< class T, const IID *piid >
|
||||
struct pointee< ATL::CComQIPtr<T, piid> > :
|
||||
mpl::identity<T>
|
||||
{ };
|
||||
|
||||
template< class E, class Allocator >
|
||||
struct pointee< ATL::CHeapPtr<E, Allocator> > :
|
||||
mpl::identity<E>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct pointee< ATL::CAdapt<T> > :
|
||||
pointee<T>
|
||||
{ };
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
// extended customizations
|
||||
//
|
||||
|
||||
|
||||
#include <boost/iterator/indirect_iterator.hpp>
|
||||
#include <boost/iterator/zip_iterator.hpp>
|
||||
#include <boost/range/detail/microsoft.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <atlbase.h> // CComBSTR
|
||||
|
||||
|
||||
namespace boost { namespace range_detail_microsoft {
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
|
||||
struct atl_array_functions :
|
||||
array_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x) // redefine
|
||||
{
|
||||
return x.GetData() + x.GetCount(); // no 'GetSize()'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class E, class ETraits >
|
||||
struct customization< ATL::CAtlArray<E, ETraits> > :
|
||||
atl_array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef E val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class E >
|
||||
struct customization< ATL::CAutoPtrArray<E> > :
|
||||
atl_array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
// ATL::CAutoPtr/CHeapPtr is no assignable.
|
||||
typedef ATL::CAutoPtr<E> val_t;
|
||||
typedef val_t *miter_t;
|
||||
typedef val_t const *citer_t;
|
||||
|
||||
typedef indirect_iterator<miter_t> mutable_iterator;
|
||||
typedef indirect_iterator<citer_t> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class I, const IID *piid >
|
||||
struct customization< ATL::CInterfaceArray<I, piid> > :
|
||||
atl_array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ATL::CComQIPtr<I, piid> val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class E, class ETraits >
|
||||
struct customization< ATL::CAtlList<E, ETraits> > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef E val_t;
|
||||
|
||||
typedef list_iterator<X, val_t> mutable_iterator;
|
||||
typedef list_iterator<X const, val_t const> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
struct indirected_list_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
typedef typename Iterator::base_type base_t; // == list_iterator
|
||||
return Iterator(base_t(x, x.GetHeadPosition()));
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
typedef typename Iterator::base_type base_t;
|
||||
return Iterator(base_t(x, POSITION(0)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class E >
|
||||
struct customization< ATL::CAutoPtrList<E> > :
|
||||
indirected_list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ATL::CAutoPtr<E> val_t;
|
||||
typedef list_iterator<X, val_t> miter_t;
|
||||
typedef list_iterator<X const, val_t const> citer_t;
|
||||
|
||||
typedef indirect_iterator<miter_t> mutable_iterator;
|
||||
typedef indirect_iterator<citer_t> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class E, class Allocator >
|
||||
struct customization< ATL::CHeapPtrList<E, Allocator> > :
|
||||
indirected_list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ATL::CHeapPtr<E, Allocator> val_t;
|
||||
typedef list_iterator<X, val_t> miter_t;
|
||||
typedef list_iterator<X const, val_t const> citer_t;
|
||||
|
||||
typedef indirect_iterator<miter_t> mutable_iterator;
|
||||
typedef indirect_iterator<citer_t> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class I, const IID *piid >
|
||||
struct customization< ATL::CInterfaceList<I, piid> > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ATL::CComQIPtr<I, piid> val_t;
|
||||
|
||||
typedef list_iterator<X, val_t> mutable_iterator;
|
||||
typedef list_iterator<X const, val_t const> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
|
||||
struct atl_rb_tree_tag
|
||||
{ };
|
||||
|
||||
template< >
|
||||
struct customization< atl_rb_tree_tag > :
|
||||
indirected_list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef typename X::CPair val_t;
|
||||
|
||||
typedef list_iterator<X, val_t *, val_t *> miter_t;
|
||||
typedef list_iterator<X const, val_t const *, val_t const *> citer_t;
|
||||
|
||||
typedef indirect_iterator<miter_t> mutable_iterator;
|
||||
typedef indirect_iterator<citer_t> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class K, class V, class KTraits, class VTraits >
|
||||
struct customization< ATL::CAtlMap<K, V, KTraits, VTraits> > :
|
||||
customization< atl_rb_tree_tag >
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x) // redefine
|
||||
{
|
||||
typedef typename Iterator::base_type base_t; // == list_iterator
|
||||
return Iterator(base_t(x, x.GetStartPosition())); // no 'GetHeadPosition'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
|
||||
struct atl_string_tag
|
||||
{ };
|
||||
|
||||
template< >
|
||||
struct customization< atl_string_tag >
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef typename X::PXSTR mutable_iterator;
|
||||
typedef typename X::PCXSTR const_iterator;
|
||||
};
|
||||
|
||||
template< class Iterator, class X >
|
||||
typename mutable_<Iterator, X>::type begin(X& x)
|
||||
{
|
||||
return x.GetBuffer(0);
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X const& x)
|
||||
{
|
||||
return x.GetString();
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return begin<Iterator>(x) + x.GetLength();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class BaseType, const int t_nSize >
|
||||
struct customization< ATL::CStaticString<BaseType, t_nSize> >
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef BaseType const *mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X const& x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X const& x)
|
||||
{
|
||||
return begin<Iterator>(x) + X::GetLength();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ATL::CComBSTR >
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef OLECHAR *mutable_iterator;
|
||||
typedef OLECHAR const *const_iterator;
|
||||
};
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return x.operator BSTR();
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return begin<Iterator>(x) + x.Length();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// simples
|
||||
//
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
template< class T, class TEqual >
|
||||
struct customization< ATL::CSimpleArray<T, TEqual> > :
|
||||
#else
|
||||
template< class T >
|
||||
struct customization< ATL::CSimpleArray<T> > :
|
||||
#endif
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef T val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#if defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
|
||||
template< class T >
|
||||
struct customization< ATL::CSimpleValArray<T> > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef T val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
template< class TKey, class TVal, class TEqual >
|
||||
struct customization< ATL::CSimpleMap<TKey, TVal, TEqual> >
|
||||
#else
|
||||
template< class TKey, class TVal >
|
||||
struct customization< ATL::CSimpleMap<TKey, TVal> >
|
||||
#endif
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef TKey k_val_t;
|
||||
typedef k_val_t *k_miter_t;
|
||||
typedef k_val_t const *k_citer_t;
|
||||
|
||||
typedef TVal v_val_t;
|
||||
typedef v_val_t *v_miter_t;
|
||||
typedef v_val_t const *v_citer_t;
|
||||
|
||||
// Topic:
|
||||
// 'std::pair' can't contain references
|
||||
// because of reference to reference problem.
|
||||
|
||||
typedef zip_iterator< tuple<k_miter_t, v_miter_t> > mutable_iterator;
|
||||
typedef zip_iterator< tuple<k_citer_t, v_citer_t> > const_iterator;
|
||||
};
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return Iterator(boost::make_tuple(x.m_aKey, x.m_aVal));
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return Iterator(boost::make_tuple(x.m_aKey + x.GetSize(), x.m_aVal + x.GetSize()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} } // namespace boost::range_detail_microsoft
|
||||
|
||||
|
||||
|
||||
|
||||
// range customizations
|
||||
//
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CAtlArray, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CAutoPtrArray, 1
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CInterfaceArray, (class)(const IID *)
|
||||
)
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CAtlList, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CAutoPtrList, 1
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CHeapPtrList, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CInterfaceList, (class)(const IID *)
|
||||
)
|
||||
|
||||
|
||||
//maps
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CAtlMap, 4
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_rb_tree_tag,
|
||||
(ATL, BOOST_PP_NIL), CRBTree, 4
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_rb_tree_tag,
|
||||
(ATL, BOOST_PP_NIL), CRBMap, 4
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_rb_tree_tag,
|
||||
(ATL, BOOST_PP_NIL), CRBMultiMap, 4
|
||||
)
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLESTRING)
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_string_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleStringT, (class)(bool)
|
||||
)
|
||||
#else
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_string_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleStringT, 1
|
||||
)
|
||||
#endif
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_string_tag,
|
||||
(ATL, BOOST_PP_NIL), CStringT, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::atl_string_tag,
|
||||
(ATL, BOOST_PP_NIL), CFixedStringT, (class)(int)
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CStaticString, (class)(const int)
|
||||
)
|
||||
|
||||
|
||||
#endif // !defined(BOOST_RANGE_ATL_NO_COLLECTIONS)
|
||||
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CComBSTR
|
||||
)
|
||||
|
||||
|
||||
// simples
|
||||
//
|
||||
#if !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleArray, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleMap, 3
|
||||
)
|
||||
|
||||
#else
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleArray, 1
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleMap, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
(ATL, BOOST_PP_NIL), CSimpleValArray, 1
|
||||
)
|
||||
|
||||
#endif // !defined(BOOST_RANGE_ATL_HAS_OLD_CSIMPLE_XXX)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -60,7 +60,8 @@ namespace boost {
|
||||
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;
|
||||
//typedef typename range_iterator<const T>::type range_const_iterator;
|
||||
|
||||
void constraints()
|
||||
{
|
||||
function_requires<
|
||||
@ -75,12 +76,11 @@ namespace boost {
|
||||
}
|
||||
void const_constraints(const T& a)
|
||||
{
|
||||
ci = boost::begin(a);
|
||||
ci = boost::end(a);
|
||||
//ci = boost::begin(a);
|
||||
//ci = boost::end(a);
|
||||
}
|
||||
T a;
|
||||
range_iterator i;
|
||||
range_const_iterator ci;
|
||||
bool b;
|
||||
};
|
||||
|
||||
@ -88,7 +88,6 @@ namespace boost {
|
||||
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<
|
||||
@ -99,17 +98,13 @@ namespace boost {
|
||||
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<
|
||||
@ -126,17 +121,18 @@ namespace boost {
|
||||
}
|
||||
void const_constraints(const T& a)
|
||||
{
|
||||
ci = boost::rbegin(a);
|
||||
ci = boost::rend(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 {
|
||||
typedef typename range_size<T>::type range_size;
|
||||
|
||||
void constraints()
|
||||
{
|
||||
function_requires<
|
||||
@ -147,7 +143,12 @@ namespace boost {
|
||||
typename range_iterator<T>::type
|
||||
>
|
||||
>();
|
||||
}
|
||||
|
||||
s = boost::size(a);
|
||||
}
|
||||
|
||||
T a;
|
||||
range_size s;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
@ -57,55 +57,15 @@ namespace boost
|
||||
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 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 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 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 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>( 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>( boost_range_array, tag() );
|
||||
*/
|
||||
return boost_range_array + sz;
|
||||
}
|
||||
|
||||
@ -119,54 +79,15 @@ 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 )
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz], int )
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline std::size_t array_size( T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
|
||||
{
|
||||
return sz - 1;
|
||||
}
|
||||
|
||||
template< class T, std::size_t sz >
|
||||
inline std::size_t array_size( const T BOOST_RANGE_ARRAY_REF()[sz], char_or_wchar_t_array_tag )
|
||||
{
|
||||
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>( 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>( boost_range_array, tag() );
|
||||
*/
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
@ -1,97 +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/
|
||||
//
|
||||
|
||||
#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
|
@ -1,92 +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/
|
||||
//
|
||||
|
||||
#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
|
935
include/boost/range/detail/microsoft.hpp
Normal file
935
include/boost/range/detail/microsoft.hpp
Normal file
@ -0,0 +1,935 @@
|
||||
#ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_HPP
|
||||
|
||||
|
||||
|
||||
|
||||
// Boost.Range MFC/ATL Extension
|
||||
//
|
||||
// Copyright Shunsuke Sogame 2005-2006.
|
||||
// Distributed under 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)
|
||||
|
||||
|
||||
|
||||
|
||||
// config
|
||||
//
|
||||
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1 1
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end
|
||||
#else
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_range_begin range_begin
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_range_end range_end
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// yet another customization way
|
||||
//
|
||||
|
||||
|
||||
#include <boost/iterator/iterator_traits.hpp> // iterator_difference
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/control/iif.hpp>
|
||||
#include <boost/preprocessor/comma_if.hpp>
|
||||
#include <boost/preprocessor/detail/is_unary.hpp>
|
||||
#include <boost/preprocessor/list/for_each.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/seq/for_each_i.hpp>
|
||||
#include <boost/preprocessor/seq/size.hpp>
|
||||
#include <boost/preprocessor/tuple/eat.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/utility/enable_if.hpp> // disable_if
|
||||
|
||||
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
|
||||
#include <boost/range/mutable_iterator.hpp>
|
||||
#else
|
||||
#include <iterator> // distance
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost { namespace range_detail_microsoft {
|
||||
|
||||
|
||||
// customization point
|
||||
//
|
||||
|
||||
template< class Tag >
|
||||
struct customization;
|
||||
|
||||
|
||||
template< class T >
|
||||
struct customization_tag;
|
||||
|
||||
|
||||
struct using_type_as_tag
|
||||
{ };
|
||||
|
||||
|
||||
// Topic:
|
||||
// In fact, it is unnecessary for VC++.
|
||||
// VC++'s behavior seems conforming, while GCC fails without this.
|
||||
template< class Iterator, class T >
|
||||
struct mutable_ :
|
||||
disable_if< is_const<T>, Iterator >
|
||||
{ };
|
||||
|
||||
|
||||
// helpers
|
||||
//
|
||||
|
||||
template< class Tag, class T >
|
||||
struct customization_tag_of
|
||||
{
|
||||
typedef typename mpl::if_< is_same<using_type_as_tag, Tag>,
|
||||
T,
|
||||
Tag
|
||||
>::type type;
|
||||
};
|
||||
|
||||
|
||||
template< class T >
|
||||
struct customization_of
|
||||
{
|
||||
typedef typename remove_cv<T>::type bare_t;
|
||||
typedef typename customization_tag<bare_t>::type tag_t;
|
||||
typedef customization<tag_t> type;
|
||||
};
|
||||
|
||||
|
||||
template< class T >
|
||||
struct mutable_iterator_of
|
||||
{
|
||||
typedef typename remove_cv<T>::type bare_t;
|
||||
typedef typename customization_of<bare_t>::type cust_t;
|
||||
typedef typename cust_t::template meta<bare_t>::mutable_iterator type;
|
||||
};
|
||||
|
||||
|
||||
template< class T >
|
||||
struct const_iterator_of
|
||||
{
|
||||
typedef typename remove_cv<T>::type bare_t;
|
||||
typedef typename customization_of<bare_t>::type cust_t;
|
||||
typedef typename cust_t::template meta<bare_t>::const_iterator type;
|
||||
};
|
||||
|
||||
|
||||
template< class T >
|
||||
struct size_type_of
|
||||
{
|
||||
typedef typename range_detail_microsoft::mutable_iterator_of<T>::type miter_t;
|
||||
typedef typename iterator_difference<miter_t>::type type;
|
||||
};
|
||||
|
||||
|
||||
template< class T > inline
|
||||
typename mutable_iterator_of<T>::type
|
||||
begin_of(T& x)
|
||||
{
|
||||
typedef typename customization_of<T>::type cust_t;
|
||||
return cust_t().template begin<typename mutable_iterator_of<T>::type>(x);
|
||||
}
|
||||
|
||||
|
||||
template< class T > inline
|
||||
typename const_iterator_of<T>::type
|
||||
begin_of(T const& x)
|
||||
{
|
||||
typedef typename customization_of<T>::type cust_t;
|
||||
return cust_t().template begin<typename const_iterator_of<T>::type>(x);
|
||||
}
|
||||
|
||||
|
||||
template< class T > inline
|
||||
typename mutable_iterator_of<T>::type
|
||||
end_of(T& x)
|
||||
{
|
||||
typedef typename customization_of<T>::type cust_t;
|
||||
return cust_t().template end<typename mutable_iterator_of<T>::type>(x);
|
||||
}
|
||||
|
||||
|
||||
template< class T > inline
|
||||
typename const_iterator_of<T>::type
|
||||
end_of(T const& x)
|
||||
{
|
||||
typedef typename customization_of<T>::type cust_t;
|
||||
return cust_t().template end<typename const_iterator_of<T>::type>(x);
|
||||
}
|
||||
|
||||
|
||||
#if defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
|
||||
|
||||
template< class T > inline
|
||||
typename size_type_of<T>::type
|
||||
size_of(T const& x)
|
||||
{
|
||||
return std::distance(boost::begin(x), boost::end(x));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
template< class Range >
|
||||
struct compatible_mutable_iterator :
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>
|
||||
{ };
|
||||
|
||||
|
||||
} } // namespace boost::range_detail_microsoft
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
|
||||
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op, ~, NamespaceList) \
|
||||
/**/
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op(r, data, elem) \
|
||||
namespace elem { \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
|
||||
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op, ~, NamespaceList) \
|
||||
/**/
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op(r, data, elem) \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op(r, data, elem) \
|
||||
:: elem \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(Tag, NamespaceList, Name) \
|
||||
namespace boost { namespace range_detail_microsoft { \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
} } \
|
||||
\
|
||||
namespace boost { \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
} \
|
||||
\
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name) \
|
||||
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) :: Name \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, Fullname) \
|
||||
template< > \
|
||||
struct customization_tag< Fullname > : \
|
||||
customization_tag_of< Tag, Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
// metafunctions
|
||||
//
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(Fullname) \
|
||||
template< > \
|
||||
struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
|
||||
range_detail_microsoft::mutable_iterator_of< Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(Fullname) \
|
||||
template< > \
|
||||
struct range_const_iterator< Fullname > : \
|
||||
range_detail_microsoft::const_iterator_of< Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(Fullname) \
|
||||
template< > \
|
||||
struct range_size< Fullname > : \
|
||||
range_detail_microsoft::size_type_of< Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
// functions
|
||||
//
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(Fullname) \
|
||||
inline \
|
||||
boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::begin_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(Fullname) \
|
||||
inline \
|
||||
boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::begin_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(Fullname) \
|
||||
inline \
|
||||
boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::end_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(Fullname) \
|
||||
inline \
|
||||
boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::end_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
|
||||
inline \
|
||||
boost::range_detail_microsoft::size_type_of< Fullname >::type \
|
||||
boost_range_size(Fullname const& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::size_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(Tag, NamespaceList, Name, ParamSeqOrCount) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl( \
|
||||
Tag, NamespaceList, Name, \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
|
||||
) \
|
||||
/**/
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
|
||||
BOOST_PP_IIF(BOOST_PP_IS_UNARY(ParamSeqOrCount), \
|
||||
ParamSeqOrCount BOOST_PP_TUPLE_EAT(3), \
|
||||
BOOST_PP_REPEAT \
|
||||
)(ParamSeqOrCount, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op, ~) \
|
||||
/**/
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op(z, n, _) \
|
||||
(class) \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl(Tag, NamespaceList, Name, ParamSeq) \
|
||||
namespace boost { namespace range_detail_microsoft { \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag( \
|
||||
Tag, \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
} } \
|
||||
\
|
||||
namespace boost { \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
\
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
} \
|
||||
\
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size( \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
) \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq) \
|
||||
BOOST_PP_SEQ_FOR_EACH_I(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op, ~, ParamSeq) \
|
||||
/**/
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op(r, data, i, elem) \
|
||||
BOOST_PP_COMMA_IF(i) elem BOOST_PP_CAT(T, i) \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
|
||||
BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) \
|
||||
:: Name < BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(ParamSeq), T) > \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag(Tag, Params, Fullname) \
|
||||
template< Params > \
|
||||
struct customization_tag< Fullname > : \
|
||||
customization_tag_of< Tag, Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
// metafunctions
|
||||
//
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator(Params, Fullname) \
|
||||
template< Params > \
|
||||
struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
|
||||
range_detail_microsoft::mutable_iterator_of< Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator(Params, Fullname) \
|
||||
template< Params > \
|
||||
struct range_const_iterator< Fullname > : \
|
||||
range_detail_microsoft::const_iterator_of< Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type(Params, Fullname) \
|
||||
template< Params > \
|
||||
struct range_size< Fullname > : \
|
||||
range_detail_microsoft::size_type_of< Fullname > \
|
||||
{ }; \
|
||||
/**/
|
||||
|
||||
|
||||
// functions
|
||||
//
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin(Params, Fullname) \
|
||||
template< Params > inline \
|
||||
typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::begin_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const(Params, Fullname) \
|
||||
template< Params > inline \
|
||||
typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::begin_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end(Params, Fullname) \
|
||||
template< Params > inline \
|
||||
typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::end_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const(Params, Fullname) \
|
||||
template< Params > inline \
|
||||
typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::end_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
|
||||
/**/
|
||||
|
||||
#else
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
|
||||
template< Params > inline \
|
||||
typename boost::range_detail_microsoft::size_type_of< Fullname >::type \
|
||||
boost_range_size(Fullname const& x) \
|
||||
{ \
|
||||
return boost::range_detail_microsoft::size_of(x); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// list_iterator and helpers
|
||||
//
|
||||
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
|
||||
// POSITION's header is undocumented, so is NULL.
|
||||
//
|
||||
struct __POSITION; // incomplete, but used as just a pointer.
|
||||
typedef __POSITION *POSITION;
|
||||
|
||||
|
||||
namespace boost { namespace range_detail_microsoft {
|
||||
|
||||
|
||||
template<
|
||||
class ListT,
|
||||
class Value,
|
||||
class Reference,
|
||||
class Traversal
|
||||
>
|
||||
struct list_iterator;
|
||||
|
||||
|
||||
template<
|
||||
class ListT,
|
||||
class Value,
|
||||
class Reference,
|
||||
class Traversal
|
||||
>
|
||||
struct list_iterator_super
|
||||
{
|
||||
typedef typename mpl::if_< is_same<use_default, Reference>,
|
||||
Value&,
|
||||
Reference
|
||||
>::type ref_t;
|
||||
|
||||
typedef typename mpl::if_< is_same<use_default, Traversal>,
|
||||
bidirectional_traversal_tag,
|
||||
Traversal
|
||||
>::type trv_t;
|
||||
|
||||
typedef iterator_facade<
|
||||
list_iterator<ListT, Value, Reference, Traversal>,
|
||||
Value,
|
||||
trv_t,
|
||||
ref_t
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
template<
|
||||
class ListT,
|
||||
class Value,
|
||||
class Reference = use_default,
|
||||
class Traversal = use_default
|
||||
>
|
||||
struct list_iterator :
|
||||
list_iterator_super<ListT, Value, Reference, Traversal>::type
|
||||
{
|
||||
private:
|
||||
typedef list_iterator self_t;
|
||||
typedef typename list_iterator_super<ListT, Value, Reference, Traversal>::type super_t;
|
||||
typedef typename super_t::reference ref_t;
|
||||
|
||||
public:
|
||||
explicit list_iterator()
|
||||
{ }
|
||||
|
||||
explicit list_iterator(ListT& lst, POSITION pos) :
|
||||
m_plst(boost::addressof(lst)), m_pos(pos)
|
||||
{ }
|
||||
|
||||
template< class, class, class, class > friend struct list_iterator;
|
||||
template< class ListT_, class Value_, class Reference_, class Traversal_>
|
||||
list_iterator(list_iterator<ListT_, Value_, Reference_, Traversal_> const& other) :
|
||||
m_plst(other.m_plst), m_pos(other.m_pos)
|
||||
{ }
|
||||
|
||||
private:
|
||||
ListT *m_plst;
|
||||
POSITION m_pos;
|
||||
|
||||
friend class iterator_core_access;
|
||||
ref_t dereference() const
|
||||
{
|
||||
BOOST_ASSERT(m_pos != 0 && "out of range");
|
||||
return m_plst->GetAt(m_pos);
|
||||
}
|
||||
|
||||
// A B C D x
|
||||
// Head Tail NULL(0)
|
||||
//
|
||||
void increment()
|
||||
{
|
||||
BOOST_ASSERT(m_pos != 0 && "out of range");
|
||||
m_plst->GetNext(m_pos);
|
||||
}
|
||||
|
||||
void decrement()
|
||||
{
|
||||
if (m_pos == 0) {
|
||||
m_pos = m_plst->GetTailPosition();
|
||||
return;
|
||||
}
|
||||
|
||||
m_plst->GetPrev(m_pos);
|
||||
}
|
||||
|
||||
bool equal(self_t const& other) const
|
||||
{
|
||||
BOOST_ASSERT(m_plst == other.m_plst && "iterators incompatible");
|
||||
return m_pos == other.m_pos;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// customization helpers
|
||||
//
|
||||
|
||||
struct array_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return x.GetData();
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return begin<Iterator>(x) + x.GetSize();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct list_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return Iterator(x, x.GetHeadPosition());
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return Iterator(x, POSITION(0));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} } // namespace boost::range_detail_microsoft
|
||||
|
||||
|
||||
|
||||
|
||||
// test
|
||||
//
|
||||
|
||||
|
||||
#if defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <boost/range/empty.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/mutable_iterator.hpp>
|
||||
#include <boost/range/rbegin.hpp>
|
||||
#include <boost/range/rend.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace range_detail_microsoft {
|
||||
|
||||
|
||||
template< class Range1, class Range2 >
|
||||
bool test_equals(Range1 const& rng1, Range2 const& rng2)
|
||||
{
|
||||
return
|
||||
boost::distance(rng1) == boost::distance(rng2) &&
|
||||
std::equal(boost::begin(rng1), boost::end(rng1), boost::begin(rng2))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
template< class AssocContainer, class PairT >
|
||||
bool test_find_key_and_mapped(AssocContainer const& ac, PairT const& pa)
|
||||
{
|
||||
typedef typename boost::range_const_iterator<AssocContainer>::type iter_t;
|
||||
for (iter_t it = boost::const_begin(ac), last = boost::const_end(ac); it != last; ++it) {
|
||||
if (it->first == pa.first && it->second == pa.second)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// test functions
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
bool test_emptiness(Range& )
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
Range emptyRng;
|
||||
result = result && boost::empty(emptyRng);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
bool test_trivial(Range& rng)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
// convertibility check
|
||||
typedef typename range_const_iterator<Range>::type citer_t;
|
||||
citer_t cit = boost::begin(rng);
|
||||
(void)cit; // unused
|
||||
|
||||
// mutability check
|
||||
typedef typename range_value<Range>::type val_t;
|
||||
val_t v = *boost::begin(rng);
|
||||
*boost::begin(rng) = v;
|
||||
result = result && *boost::begin(rng) == v;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
bool test_forward(Range& rng)
|
||||
{
|
||||
boost::function_requires< ForwardRangeConcept<Range> >();
|
||||
|
||||
bool result = (test_trivial)(rng);
|
||||
|
||||
typedef typename range_value<Range>::type val_t;
|
||||
|
||||
std::vector<val_t> saved;
|
||||
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
|
||||
std::rotate(boost::begin(saved), boost::next(boost::begin(saved)), boost::end(saved));
|
||||
|
||||
std::rotate(boost::begin(rng), boost::next(boost::begin(rng)), boost::end(rng));
|
||||
|
||||
return result && (test_equals)(saved, rng);
|
||||
};
|
||||
|
||||
|
||||
template< class Range >
|
||||
bool test_bidirectional(Range& rng)
|
||||
{
|
||||
boost::function_requires< BidirectionalRangeConcept<Range> >();
|
||||
|
||||
bool result = (test_forward)(rng);
|
||||
|
||||
typedef typename range_value<Range>::type val_t;
|
||||
|
||||
std::vector<val_t> saved;
|
||||
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
|
||||
|
||||
result = result && (test_equals)(
|
||||
boost::make_iterator_range(boost::rbegin(saved), boost::rend(saved)),
|
||||
boost::make_iterator_range(boost::rbegin(rng), boost::rend(rng))
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
bool test_random_access(Range& rng)
|
||||
{
|
||||
boost::function_requires< RandomAccessRangeConcept<Range> >();
|
||||
|
||||
bool result = (test_bidirectional)(rng);
|
||||
|
||||
typedef typename range_value<Range>::type val_t;
|
||||
|
||||
std::vector<val_t> saved;
|
||||
std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
|
||||
std::sort(boost::begin(saved), boost::end(saved));
|
||||
|
||||
std::random_shuffle(boost::begin(rng), boost::end(rng));
|
||||
std::sort(boost::begin(rng), boost::end(rng));
|
||||
result = result && (test_equals)(rng, saved);
|
||||
|
||||
std::random_shuffle(boost::begin(rng), boost::end(rng));
|
||||
std::stable_sort(boost::begin(rng), boost::end(rng));
|
||||
result = result && (test_equals)(rng, saved);
|
||||
|
||||
std::random_shuffle(boost::begin(rng), boost::end(rng));
|
||||
std::partial_sort(boost::begin(rng), boost::end(rng), boost::end(rng));
|
||||
result = result && (test_equals)(rng, saved);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// initializer
|
||||
//
|
||||
|
||||
template< class ArrayT, class SampleRange >
|
||||
bool test_init_array(ArrayT& arr, SampleRange const& sample)
|
||||
{
|
||||
typedef typename range_const_iterator<SampleRange>::type iter_t;
|
||||
typedef typename range_value<SampleRange>::type val_t;
|
||||
|
||||
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
|
||||
val_t v = *it; // works around ATL3 CSimpleArray
|
||||
arr.Add(v);
|
||||
}
|
||||
|
||||
return (test_equals)(arr, sample);
|
||||
}
|
||||
|
||||
|
||||
template< class ListT, class SampleRange >
|
||||
bool test_init_list(ListT& lst, SampleRange const& sample)
|
||||
{
|
||||
typedef typename range_const_iterator<SampleRange>::type iter_t;
|
||||
|
||||
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
|
||||
lst.AddTail(*it);
|
||||
}
|
||||
|
||||
return (test_equals)(lst, sample);
|
||||
}
|
||||
|
||||
|
||||
template< class StringT, class SampleRange >
|
||||
bool test_init_string(StringT& str, SampleRange const& sample)
|
||||
{
|
||||
typedef typename range_const_iterator<SampleRange>::type iter_t;
|
||||
typedef typename range_value<SampleRange>::type val_t;
|
||||
|
||||
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
|
||||
str += *it;
|
||||
}
|
||||
|
||||
return (test_equals)(str, sample);
|
||||
}
|
||||
|
||||
|
||||
template< class MapT, class SampleMap >
|
||||
bool test_init_map(MapT& map, SampleMap const& sample)
|
||||
{
|
||||
typedef typename range_const_iterator<SampleMap>::type iter_t;
|
||||
|
||||
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
|
||||
map.SetAt(it->first, it->second);
|
||||
}
|
||||
|
||||
return boost::distance(map) == boost::distance(sample);
|
||||
}
|
||||
|
||||
|
||||
// metafunction test
|
||||
//
|
||||
|
||||
template< class Range, class Iter >
|
||||
struct test_mutable_iter :
|
||||
boost::is_same< typename boost::BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>::type, Iter >
|
||||
{ };
|
||||
|
||||
|
||||
template< class Range, class Iter >
|
||||
struct test_const_iter :
|
||||
boost::is_same< typename boost::range_const_iterator<Range>::type, Iter >
|
||||
{ };
|
||||
|
||||
|
||||
} } // namespace boost::range_detail_microsoft
|
||||
|
||||
|
||||
#endif // defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -24,13 +24,45 @@
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< typename C >
|
||||
struct range_iterator
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
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;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
@ -36,6 +36,9 @@
|
||||
#endif
|
||||
#include <cstddef>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400)
|
||||
#pragma warning( disable : 4996 )
|
||||
#endif
|
||||
|
||||
/*! \file
|
||||
Defines the \c iterator_class and related functions.
|
||||
@ -348,10 +351,21 @@ namespace boost
|
||||
return *--last;
|
||||
}
|
||||
|
||||
reference operator[]( size_type sz ) const
|
||||
reference operator[]( size_type at ) const
|
||||
{
|
||||
BOOST_ASSERT( sz < size() );
|
||||
return m_Begin[sz];
|
||||
BOOST_ASSERT( at < size() );
|
||||
return m_Begin[at];
|
||||
}
|
||||
|
||||
//
|
||||
// When storing transform iterators, operator[]()
|
||||
// fails because it returns by reference. Therefore
|
||||
// operator()() is provided for these cases.
|
||||
//
|
||||
value_type operator()( size_type at ) const
|
||||
{
|
||||
BOOST_ASSERT( at < size() );
|
||||
return m_Begin[at];
|
||||
}
|
||||
|
||||
iterator_range& advance_begin( difference_type n )
|
||||
|
984
include/boost/range/mfc.hpp
Normal file
984
include/boost/range/mfc.hpp
Normal file
@ -0,0 +1,984 @@
|
||||
#ifndef BOOST_RANGE_MFC_HPP
|
||||
#define BOOST_RANGE_MFC_HPP
|
||||
|
||||
|
||||
|
||||
|
||||
// Boost.Range MFC Extension
|
||||
//
|
||||
// Copyright Shunsuke Sogame 2005-2006.
|
||||
// Distributed under 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)
|
||||
|
||||
|
||||
|
||||
|
||||
// config
|
||||
//
|
||||
|
||||
|
||||
#include <afx.h> // _MFC_VER
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
#if (_MFC_VER < 0x0700) // dubious
|
||||
#define BOOST_RANGE_MFC_NO_CPAIR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
|
||||
#if (_MFC_VER < 0x0700) // dubious
|
||||
#define BOOST_RANGE_MFC_HAS_LEGACY_STRING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// A const collection of old MFC doesn't return const reference.
|
||||
//
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
#if (_MFC_VER < 0x0700) // dubious
|
||||
#define BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
// forward declarations
|
||||
//
|
||||
|
||||
|
||||
template< class Type, class ArgType >
|
||||
class CArray;
|
||||
|
||||
template< class Type, class ArgType >
|
||||
class CList;
|
||||
|
||||
template< class Key, class ArgKey, class Mapped, class ArgMapped >
|
||||
class CMap;
|
||||
|
||||
template< class BaseClass, class PtrType >
|
||||
class CTypedPtrArray;
|
||||
|
||||
template< class BaseClass, class PtrType >
|
||||
class CTypedPtrList;
|
||||
|
||||
template< class BaseClass, class KeyPtrType, class MappedPtrType >
|
||||
class CTypedPtrMap;
|
||||
|
||||
|
||||
|
||||
|
||||
// extended customizations
|
||||
//
|
||||
|
||||
|
||||
#include <cstddef> // ptrdiff_t
|
||||
#include <utility> // pair
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/range/atl.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/range/detail/microsoft.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/remove_pointer.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <afx.h> // legacy CString
|
||||
#include <afxcoll.h> // CXXXArray, CXXXList, CMapXXXToXXX
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
namespace boost { namespace range_detail_microsoft {
|
||||
|
||||
|
||||
// mfc_ptr_array_iterator
|
||||
//
|
||||
// 'void **' is not convertible to 'void const **',
|
||||
// so we define...
|
||||
//
|
||||
|
||||
template< class ArrayT, class PtrType >
|
||||
struct mfc_ptr_array_iterator;
|
||||
|
||||
template< class ArrayT, class PtrType >
|
||||
struct mfc_ptr_array_iterator_super
|
||||
{
|
||||
typedef iterator_adaptor<
|
||||
mfc_ptr_array_iterator<ArrayT, PtrType>,
|
||||
std::ptrdiff_t, // Base!
|
||||
PtrType, // Value
|
||||
random_access_traversal_tag,
|
||||
use_default,
|
||||
std::ptrdiff_t // Difference
|
||||
> type;
|
||||
};
|
||||
|
||||
template< class ArrayT, class PtrType >
|
||||
struct mfc_ptr_array_iterator :
|
||||
mfc_ptr_array_iterator_super<ArrayT, PtrType>::type
|
||||
{
|
||||
private:
|
||||
typedef mfc_ptr_array_iterator self_t;
|
||||
typedef typename mfc_ptr_array_iterator_super<ArrayT, PtrType>::type super_t;
|
||||
typedef typename super_t::reference ref_t;
|
||||
|
||||
public:
|
||||
explicit mfc_ptr_array_iterator()
|
||||
{ }
|
||||
|
||||
explicit mfc_ptr_array_iterator(ArrayT& arr, INT_PTR index) :
|
||||
super_t(index), m_parr(boost::addressof(arr))
|
||||
{ }
|
||||
|
||||
template< class, class > friend struct mfc_ptr_array_iterator;
|
||||
template< class ArrayT_, class PtrType_ >
|
||||
mfc_ptr_array_iterator(mfc_ptr_array_iterator<ArrayT_, PtrType_> const& other) :
|
||||
super_t(other.base()), m_parr(other.m_parr)
|
||||
{ }
|
||||
|
||||
private:
|
||||
ArrayT *m_parr;
|
||||
|
||||
friend class iterator_core_access;
|
||||
ref_t dereference() const
|
||||
{
|
||||
BOOST_ASSERT(0 <= this->base() && this->base() < m_parr->GetSize() && "out of range");
|
||||
return *( m_parr->GetData() + this->base() );
|
||||
}
|
||||
|
||||
bool equal(self_t const& other) const
|
||||
{
|
||||
BOOST_ASSERT(m_parr == other.m_parr && "iterators incompatible");
|
||||
return this->base() == other.base();
|
||||
}
|
||||
};
|
||||
|
||||
struct mfc_ptr_array_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return Iterator(x, 0);
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return Iterator(x, x.GetSize());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
|
||||
template< >
|
||||
struct customization< ::CByteArray > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef BYTE val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CDWordArray > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef DWORD val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CObArray > :
|
||||
mfc_ptr_array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef mfc_ptr_array_iterator<X, CObject *> mutable_iterator;
|
||||
typedef mfc_ptr_array_iterator<X const, CObject const *> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CPtrArray > :
|
||||
mfc_ptr_array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef mfc_ptr_array_iterator<X, void *> mutable_iterator;
|
||||
typedef mfc_ptr_array_iterator<X const, void const *> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CStringArray > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ::CString val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CUIntArray > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef UINT val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CWordArray > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef WORD val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
|
||||
template< >
|
||||
struct customization< ::CObList > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef list_iterator<X, ::CObject *> mutable_iterator;
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
typedef list_iterator<X const, ::CObject const *> const_iterator;
|
||||
#else
|
||||
typedef list_iterator<X const, ::CObject const * const, ::CObject const * const> const_iterator;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CPtrList > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef list_iterator<X, void *> mutable_iterator;
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
typedef list_iterator<X const, void const *> const_iterator;
|
||||
#else
|
||||
typedef list_iterator<X const, void const * const, void const * const> const_iterator;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CStringList > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ::CString val_t;
|
||||
|
||||
typedef list_iterator<X, val_t> mutable_iterator;
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
typedef list_iterator<X const, val_t const> const_iterator;
|
||||
#else
|
||||
typedef list_iterator<X const, val_t const, val_t const> const_iterator;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// mfc_map_iterator
|
||||
//
|
||||
|
||||
template< class MapT, class KeyT, class MappedT >
|
||||
struct mfc_map_iterator;
|
||||
|
||||
template< class MapT, class KeyT, class MappedT >
|
||||
struct mfc_map_iterator_super
|
||||
{
|
||||
typedef iterator_facade<
|
||||
mfc_map_iterator<MapT, KeyT, MappedT>,
|
||||
std::pair<KeyT, MappedT>,
|
||||
forward_traversal_tag,
|
||||
std::pair<KeyT, MappedT> const
|
||||
> type;
|
||||
};
|
||||
|
||||
template< class MapT, class KeyT, class MappedT >
|
||||
struct mfc_map_iterator :
|
||||
mfc_map_iterator_super<MapT, KeyT, MappedT>::type
|
||||
{
|
||||
private:
|
||||
typedef mfc_map_iterator self_t;
|
||||
typedef typename mfc_map_iterator_super<MapT, KeyT, MappedT>::type super_t;
|
||||
typedef typename super_t::reference ref_t;
|
||||
|
||||
public:
|
||||
explicit mfc_map_iterator()
|
||||
{ }
|
||||
|
||||
explicit mfc_map_iterator(MapT const& map, POSITION pos) :
|
||||
m_pmap(boost::addressof(map)), m_posNext(pos)
|
||||
{
|
||||
increment();
|
||||
}
|
||||
|
||||
explicit mfc_map_iterator(MapT const& map) :
|
||||
m_pmap(&map), m_pos(0) // end iterator
|
||||
{ }
|
||||
|
||||
template< class, class, class > friend struct mfc_map_iterator;
|
||||
template< class MapT_, class KeyT_, class MappedT_>
|
||||
mfc_map_iterator(mfc_map_iterator<MapT_, KeyT_, MappedT_> const& other) :
|
||||
m_pmap(other.m_pmap),
|
||||
m_pos(other.m_pos), m_posNext(other.m_posNext),
|
||||
m_key(other.m_key), m_mapped(other.m_mapped)
|
||||
{ }
|
||||
|
||||
private:
|
||||
MapT const *m_pmap;
|
||||
POSITION m_pos, m_posNext;
|
||||
KeyT m_key; MappedT m_mapped;
|
||||
|
||||
friend class iterator_core_access;
|
||||
ref_t dereference() const
|
||||
{
|
||||
BOOST_ASSERT(m_pos != 0 && "out of range");
|
||||
return std::make_pair(m_key, m_mapped);
|
||||
}
|
||||
|
||||
void increment()
|
||||
{
|
||||
BOOST_ASSERT(m_pos != 0 && "out of range");
|
||||
|
||||
if (m_posNext == 0) {
|
||||
m_pos = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
m_pos = m_posNext;
|
||||
m_pmap->GetNextAssoc(m_posNext, m_key, m_mapped);
|
||||
}
|
||||
|
||||
bool equal(self_t const& other) const
|
||||
{
|
||||
BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
|
||||
return m_pos == other.m_pos;
|
||||
}
|
||||
};
|
||||
|
||||
struct mfc_map_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return Iterator(x, x.GetStartPosition());
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return Iterator(x);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
|
||||
|
||||
// mfc_cpair_map_iterator
|
||||
//
|
||||
// used by ::CMap and ::CMapStringToString
|
||||
//
|
||||
|
||||
template< class MapT, class PairT >
|
||||
struct mfc_cpair_map_iterator;
|
||||
|
||||
template< class MapT, class PairT >
|
||||
struct mfc_pget_map_iterator_super
|
||||
{
|
||||
typedef iterator_facade<
|
||||
mfc_cpair_map_iterator<MapT, PairT>,
|
||||
PairT,
|
||||
forward_traversal_tag
|
||||
> type;
|
||||
};
|
||||
|
||||
template< class MapT, class PairT >
|
||||
struct mfc_cpair_map_iterator :
|
||||
mfc_pget_map_iterator_super<MapT, PairT>::type
|
||||
{
|
||||
private:
|
||||
typedef mfc_cpair_map_iterator self_t;
|
||||
typedef typename mfc_pget_map_iterator_super<MapT, PairT>::type super_t;
|
||||
typedef typename super_t::reference ref_t;
|
||||
|
||||
public:
|
||||
explicit mfc_cpair_map_iterator()
|
||||
{ }
|
||||
|
||||
explicit mfc_cpair_map_iterator(MapT& map, PairT *pp) :
|
||||
m_pmap(boost::addressof(map)), m_pp(pp)
|
||||
{ }
|
||||
|
||||
template< class, class > friend struct mfc_cpair_map_iterator;
|
||||
template< class MapT_, class PairT_>
|
||||
mfc_cpair_map_iterator(mfc_cpair_map_iterator<MapT_, PairT_> const& other) :
|
||||
m_pmap(other.m_pmap), m_pp(other.m_pp)
|
||||
{ }
|
||||
|
||||
private:
|
||||
MapT *m_pmap;
|
||||
PairT *m_pp;
|
||||
|
||||
friend class iterator_core_access;
|
||||
ref_t dereference() const
|
||||
{
|
||||
BOOST_ASSERT(m_pp != 0 && "out of range");
|
||||
return *m_pp;
|
||||
}
|
||||
|
||||
void increment()
|
||||
{
|
||||
BOOST_ASSERT(m_pp != 0 && "out of range");
|
||||
m_pp = m_pmap->PGetNextAssoc(m_pp);
|
||||
}
|
||||
|
||||
bool equal(self_t const& other) const
|
||||
{
|
||||
BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
|
||||
return m_pp == other.m_pp;
|
||||
}
|
||||
};
|
||||
|
||||
struct mfc_cpair_map_functions
|
||||
{
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
// Workaround:
|
||||
// Assertion fails if empty.
|
||||
// MFC document is wrong.
|
||||
#if !defined(NDEBUG)
|
||||
if (x.GetCount() == 0)
|
||||
return Iterator(x, 0);
|
||||
#endif
|
||||
|
||||
return Iterator(x, x.PGetFirstAssoc());
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return Iterator(x, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapPtrToWord > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef void *key_t;
|
||||
typedef WORD mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapPtrToPtr > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef void *key_t;
|
||||
typedef void *mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapStringToOb > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ::CString key_t;
|
||||
typedef ::CObject *mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapStringToPtr > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef ::CString key_t;
|
||||
typedef void *mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapStringToString > :
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
mfc_cpair_map_functions
|
||||
#else
|
||||
mfc_map_functions
|
||||
#endif
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
typedef typename X::CPair pair_t;
|
||||
|
||||
typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
|
||||
typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
|
||||
#else
|
||||
typedef ::CString key_t;
|
||||
typedef ::CString mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapWordToOb > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef WORD key_t;
|
||||
typedef ::CObject *mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< >
|
||||
struct customization< ::CMapWordToPtr > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef WORD key_t;
|
||||
typedef void *mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// templates
|
||||
//
|
||||
|
||||
template< class Type, class ArgType >
|
||||
struct customization< ::CArray<Type, ArgType> > :
|
||||
array_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef Type val_t;
|
||||
|
||||
typedef val_t *mutable_iterator;
|
||||
typedef val_t const *const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class Type, class ArgType >
|
||||
struct customization< ::CList<Type, ArgType> > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef Type val_t;
|
||||
|
||||
typedef list_iterator<X, val_t> mutable_iterator;
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
typedef list_iterator<X const, val_t const> const_iterator;
|
||||
#else
|
||||
typedef list_iterator<X const, val_t const, val_t const> const_iterator;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class Key, class ArgKey, class Mapped, class ArgMapped >
|
||||
struct customization< ::CMap<Key, ArgKey, Mapped, ArgMapped> > :
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
mfc_cpair_map_functions
|
||||
#else
|
||||
mfc_map_functions
|
||||
#endif
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
typedef typename X::CPair pair_t;
|
||||
|
||||
typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
|
||||
typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
|
||||
#else
|
||||
typedef Key key_t;
|
||||
typedef Mapped mapped_t;
|
||||
|
||||
typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class BaseClass, class PtrType >
|
||||
struct customization< ::CTypedPtrArray<BaseClass, PtrType> >
|
||||
{
|
||||
template< class X >
|
||||
struct fun
|
||||
{
|
||||
typedef typename remove_pointer<PtrType>::type val_t;
|
||||
|
||||
typedef typename mpl::if_< is_const<X>,
|
||||
val_t const,
|
||||
val_t
|
||||
>::type val_t_;
|
||||
|
||||
typedef val_t_ * const result_type;
|
||||
|
||||
template< class PtrType_ >
|
||||
result_type operator()(PtrType_ p) const
|
||||
{
|
||||
return static_cast<result_type>(p);
|
||||
}
|
||||
};
|
||||
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef typename compatible_mutable_iterator<BaseClass>::type miter_t;
|
||||
typedef typename range_const_iterator<BaseClass>::type citer_t;
|
||||
|
||||
typedef transform_iterator<fun<X>, miter_t> mutable_iterator;
|
||||
typedef transform_iterator<fun<X const>, citer_t> const_iterator;
|
||||
};
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X& x)
|
||||
{
|
||||
return Iterator(boost::begin<BaseClass>(x), fun<X>());
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return Iterator(boost::end<BaseClass>(x), fun<X>());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template< class BaseClass, class PtrType >
|
||||
struct customization< ::CTypedPtrList<BaseClass, PtrType> > :
|
||||
list_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef typename remove_pointer<PtrType>::type val_t;
|
||||
|
||||
// not l-value
|
||||
typedef list_iterator<X, val_t * const, val_t * const> mutable_iterator;
|
||||
typedef list_iterator<X const, val_t const * const, val_t const * const> const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template< class BaseClass, class KeyPtrType, class MappedPtrType >
|
||||
struct customization< ::CTypedPtrMap<BaseClass, KeyPtrType, MappedPtrType> > :
|
||||
mfc_map_functions
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
typedef mfc_map_iterator<X, KeyPtrType, MappedPtrType> mutable_iterator;
|
||||
typedef mutable_iterator const_iterator;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
|
||||
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
|
||||
|
||||
template< >
|
||||
struct customization< ::CString >
|
||||
{
|
||||
template< class X >
|
||||
struct meta
|
||||
{
|
||||
// LPTSTR/LPCTSTR is not always defined in <tchar.h>.
|
||||
typedef TCHAR *mutable_iterator;
|
||||
typedef TCHAR const *const_iterator;
|
||||
};
|
||||
|
||||
template< class Iterator, class X >
|
||||
typename mutable_<Iterator, X>::type begin(X& x)
|
||||
{
|
||||
return x.GetBuffer(0);
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator begin(X const& x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
template< class Iterator, class X >
|
||||
Iterator end(X& x)
|
||||
{
|
||||
return begin<Iterator>(x) + x.GetLength();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
|
||||
|
||||
|
||||
} } // namespace boost::range_detail_microsoft
|
||||
|
||||
|
||||
|
||||
|
||||
// range customizations
|
||||
//
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CByteArray
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CDWordArray
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CStringArray
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CUIntArray
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CWordArray
|
||||
)
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CObList
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CPtrList
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CStringList
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CObArray
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CPtrArray
|
||||
)
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapPtrToWord
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapPtrToPtr
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapStringToOb
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapStringToPtr
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapStringToString
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapWordToOb
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMapWordToPtr
|
||||
)
|
||||
|
||||
|
||||
// templates
|
||||
//
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CArray, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CList, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CMap, 4
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CTypedPtrArray, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CTypedPtrList, 2
|
||||
)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CTypedPtrMap, 3
|
||||
)
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
|
||||
|
||||
BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
|
||||
boost::range_detail_microsoft::using_type_as_tag,
|
||||
BOOST_PP_NIL, CString
|
||||
)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -11,6 +11,10 @@
|
||||
#ifndef BOOST_RANGE_SUB_RANGE_HPP
|
||||
#define BOOST_RANGE_SUB_RANGE_HPP
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400)
|
||||
#pragma warning( disable : 4996 )
|
||||
#endif
|
||||
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
@ -38,16 +42,12 @@ namespace boost
|
||||
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 */
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || BOOST_WORKAROUND(BOOST_MSVC, == 1400)
|
||||
sub_range( const sub_range& r )
|
||||
: base( static_cast<const base&>( r ) )
|
||||
{ }
|
||||
#endif
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( ForwardRange2& r ) :
|
||||
@ -86,15 +86,11 @@ namespace boost
|
||||
{
|
||||
base::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
sub_range& operator=( sub_range r )
|
||||
sub_range& operator=( const sub_range& r )
|
||||
{
|
||||
//
|
||||
// argument passed by value to avoid
|
||||
// const_iterator to iterator conversion
|
||||
//
|
||||
base::operator=( r );
|
||||
base::operator=( static_cast<const base&>(r) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,9 @@
|
||||
|
||||
<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/examples.html">Examples</a>
|
||||
<li><a href="doc/mfc_atl.html">MFC/ATL mapping (courtesy of Shunsuke
|
||||
Sogame)</a></li>
|
||||
<li><a href="doc/portability.html">Portability</a>
|
||||
<li><a href="doc/faq.html">FAQ</a>
|
||||
<li><a href="doc/history_ack.html">History and acknowledgment</a>
|
||||
|
@ -37,7 +37,7 @@ namespace
|
||||
}
|
||||
|
||||
template< typename Range, typename T >
|
||||
inline typename boost::range_const_iterator<Range>::type
|
||||
inline typename boost::range_iterator<Range>::type
|
||||
find( const Range& c, const T& value )
|
||||
{
|
||||
return std::find( boost::begin( c ), boost::end( c ), value );
|
||||
@ -47,7 +47,7 @@ namespace
|
||||
// replace first value and return its index
|
||||
//
|
||||
template< class Range, class T >
|
||||
inline typename boost::range_size<Range>::type
|
||||
inline typename boost::range_difference<Range>::type
|
||||
my_generic_replace( Range& c, const T& value, const T& replacement )
|
||||
{
|
||||
typename boost::range_iterator<Range>::type found = find( c, value );
|
||||
|
@ -62,6 +62,8 @@ void check_array()
|
||||
BOOST_CHECK_EQUAL( end( ca ), ca + size( ca ) );
|
||||
BOOST_CHECK_EQUAL( empty( ca ),false );
|
||||
|
||||
const char A[] = "\0A";
|
||||
BOOST_CHECK_EQUAL( boost::size(A), 3u );
|
||||
}
|
||||
|
||||
using boost::unit_test::test_suite;
|
||||
|
623
test/atl.cpp
Normal file
623
test/atl.cpp
Normal file
@ -0,0 +1,623 @@
|
||||
|
||||
|
||||
// Boost.Range ATL Extension
|
||||
//
|
||||
// Copyright Shunsuke Sogame 2005-2006.
|
||||
// Distributed under 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)
|
||||
|
||||
|
||||
// #include <pstade/vodka/drink.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
|
||||
#define _ATL_NO_AUTOMATIC_NAMESPACE
|
||||
|
||||
#define BOOST_LIB_NAME boost_test_exec_monitor
|
||||
#include <boost/config/auto_link.hpp>
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_TEST
|
||||
#include <boost/range/atl.hpp> // can be placed first
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
#include <atlbase.h> // for ATL3 CSimpleArray/CSimpleValArray
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
#include <atlcoll.h>
|
||||
#include <cstringt.h>
|
||||
#include <atlsimpstr.h>
|
||||
#include <atlstr.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace brdm = boost::range_detail_microsoft;
|
||||
|
||||
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
|
||||
|
||||
template< class ArrayT, class SampleRange >
|
||||
bool test_init_auto_ptr_array(ArrayT& arr, SampleRange& sample)
|
||||
{
|
||||
typedef typename boost::range_iterator<SampleRange>::type iter_t;
|
||||
|
||||
for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
|
||||
arr.Add(*it); // moves ownership
|
||||
}
|
||||
|
||||
return boost::distance(arr) == boost::distance(sample);
|
||||
}
|
||||
|
||||
|
||||
template< class ListT, class SampleRange >
|
||||
bool test_init_auto_ptr_list(ListT& lst, SampleRange& sample)
|
||||
{
|
||||
typedef typename boost::range_iterator<SampleRange>::type iter_t;
|
||||
typedef typename boost::range_value<SampleRange>::type val_t;
|
||||
|
||||
for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
|
||||
lst.AddTail(*it); // moves ownership
|
||||
}
|
||||
|
||||
return boost::distance(lst) == boost::distance(sample);
|
||||
}
|
||||
|
||||
|
||||
// Workaround:
|
||||
// CRBTree provides no easy access function, but yes, it is the range!
|
||||
//
|
||||
template< class AtlMapT, class KeyT, class MappedT >
|
||||
bool test_atl_map_has(AtlMapT& map, const KeyT& k, const MappedT m)
|
||||
{
|
||||
typedef typename boost::range_iterator<AtlMapT>::type iter_t;
|
||||
|
||||
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
|
||||
if (it->m_key == k && it->m_value == m)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template< class AtlMapT, class MapT >
|
||||
bool test_atl_map(AtlMapT& map, const MapT& sample)
|
||||
{
|
||||
typedef typename boost::range_iterator<AtlMapT>::type iter_t;
|
||||
typedef typename boost::range_const_iterator<MapT>::type siter_t;
|
||||
|
||||
bool result = true;
|
||||
|
||||
result = result && (boost::distance(map) == boost::distance(sample));
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
{
|
||||
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
|
||||
result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->m_key, it->m_value));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
|
||||
result = result && (test_atl_map_has)(map, it->first, it->second);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template< class MapT, class SampleMap >
|
||||
bool test_init_atl_multimap(MapT& map, const SampleMap& sample)
|
||||
{
|
||||
typedef typename boost::range_const_iterator<SampleMap>::type iter_t;
|
||||
|
||||
for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
|
||||
map.Insert(it->first, it->second);
|
||||
}
|
||||
|
||||
return boost::distance(map) == boost::distance(sample);
|
||||
}
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
void test_CAtlArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ATL::CAtlArray<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class ValT, class Range >
|
||||
void test_CAutoPtrArray(Range& sample)
|
||||
{
|
||||
typedef ValT val_t;
|
||||
|
||||
typedef ATL::CAutoPtrArray<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, boost::indirect_iterator< ATL::CAutoPtr<val_t> *> >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, boost::indirect_iterator< ATL::CAutoPtr<val_t> const*> >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( ::test_init_auto_ptr_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class I, class Range >
|
||||
void test_CInterfaceArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ATL::CInterfaceArray<I> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, ATL::CComQIPtr<I> * >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, ATL::CComQIPtr<I> const* >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
void test_CAtlList(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ATL::CAtlList<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, val_t> >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, val_t const> >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class ValT, class Range >
|
||||
void test_CAutoPtrList(Range& sample)
|
||||
{
|
||||
typedef ValT val_t;
|
||||
|
||||
typedef ATL::CAutoPtrList<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t, ATL::CAutoPtr<val_t> > > >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t const, ATL::CAutoPtr<val_t> const> > >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class ValT, class Range >
|
||||
void test_CHeapPtrList(const Range& sample)
|
||||
{
|
||||
typedef ValT val_t;
|
||||
|
||||
typedef ATL::CHeapPtrList<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t, ATL::CHeapPtr<val_t> > > >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t const, ATL::CHeapPtr<val_t> const> > >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class I, class Range >
|
||||
void test_CInterfaceList(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ATL::CInterfaceList<I> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, ATL::CComQIPtr<I> > >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ATL::CComQIPtr<I> const> >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
void test_CSimpleStringT(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
|
||||
ATL::CAtlStringA,
|
||||
ATL::CAtlStringW
|
||||
>::type derived_t;
|
||||
|
||||
typedef ATL::CSimpleStringT<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, typename rng_t::PCXSTR>::value ));
|
||||
|
||||
derived_t drng;
|
||||
rng_t& rng = drng;
|
||||
BOOST_CHECK( brdm::test_init_string(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
// BOOST_CHECK( brdm::test_emptiness(rng) ); no default constructible
|
||||
}
|
||||
|
||||
|
||||
template< int n, class Range >
|
||||
void test_CFixedStringT(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
|
||||
ATL::CAtlStringA,
|
||||
ATL::CAtlStringW
|
||||
>::type base_t;
|
||||
|
||||
typedef ATL::CFixedStringT<base_t, n> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, typename rng_t::PCXSTR>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_string(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CStringT(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
|
||||
ATL::CAtlStringA, // == CStringT<char, X>
|
||||
ATL::CAtlStringW // == CStringT<wchar_t, X>
|
||||
>::type rng_t;
|
||||
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, typename rng_t::PCXSTR>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_string(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CStaticString(const Range& sample)
|
||||
{
|
||||
#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE)
|
||||
{
|
||||
typedef ATL::CStaticString<char, 20> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, char const *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, char const *>::value ));
|
||||
|
||||
rng_t rng("hello static string");
|
||||
BOOST_CHECK( *(boost::begin(rng)+4) == 'o' );
|
||||
BOOST_CHECK( *(boost::end(rng)-3) == 'i' );
|
||||
}
|
||||
|
||||
{
|
||||
typedef ATL::CStaticString<wchar_t, 40> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, wchar_t const *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, wchar_t const *>::value ));
|
||||
|
||||
rng_t rng(L"hello static string");
|
||||
BOOST_CHECK( *(boost::begin(rng)+4) == L'o' );
|
||||
BOOST_CHECK( *(boost::end(rng)-3) == L'i' );
|
||||
}
|
||||
#endif
|
||||
|
||||
(void)sample; // unused
|
||||
}
|
||||
|
||||
|
||||
#endif // !(_ATL_VER < 0x0700)
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CComBSTR(const Range& sample)
|
||||
{
|
||||
typedef ATL::CComBSTR rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, OLECHAR *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, OLECHAR const*>::value ));
|
||||
|
||||
rng_t rng(OLESTR("hello CComBSTR range!"));
|
||||
BOOST_CHECK( brdm::test_equals(rng, std::string("hello CComBSTR range!")) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
|
||||
(void)sample; // unused
|
||||
}
|
||||
|
||||
|
||||
// simples
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
void test_CSimpleArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ATL::CSimpleArray<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CSimpleMap(const Range& sample)
|
||||
{
|
||||
#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE)
|
||||
|
||||
typedef ATL::CSimpleMap<int, double> rng_t;
|
||||
|
||||
rng_t rng;
|
||||
rng.Add(3, 3.0);
|
||||
rng.Add(4, 2.0);
|
||||
|
||||
BOOST_CHECK( boost::begin(rng)->get<0>() == 3.0 );
|
||||
BOOST_CHECK( (boost::end(rng)-1)->get<1>() == 2.0 );
|
||||
|
||||
#endif
|
||||
|
||||
(void)sample; // unused
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CSimpleValArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ATL::CSimpleArray<val_t> rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
|
||||
template< class MapT >
|
||||
void test_CAtlMap(const MapT& sample)
|
||||
{
|
||||
typedef typename MapT::key_type k_t;
|
||||
typedef typename MapT::mapped_type m_t;
|
||||
|
||||
typedef ATL::CAtlMap<k_t, m_t> rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_atl_map(rng, sample) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CRBTree(const MapT& sample)
|
||||
{
|
||||
typedef typename MapT::key_type k_t;
|
||||
typedef typename MapT::mapped_type m_t;
|
||||
|
||||
typedef ATL::CRBMap<k_t, m_t> derived_t;
|
||||
typedef ATL::CRBTree<k_t, m_t> rng_t;
|
||||
|
||||
derived_t drng;
|
||||
rng_t& rng = drng;
|
||||
|
||||
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(drng, sample) );
|
||||
BOOST_CHECK( ::test_atl_map(rng, sample) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CRBMap(const MapT& sample)
|
||||
{
|
||||
typedef typename MapT::key_type k_t;
|
||||
typedef typename MapT::mapped_type m_t;
|
||||
|
||||
typedef ATL::CRBMap<k_t, m_t> rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_atl_map(rng, sample) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CRBMultiMap(const MapT& sample)
|
||||
{
|
||||
typedef typename MapT::key_type k_t;
|
||||
typedef typename MapT::mapped_type m_t;
|
||||
|
||||
typedef ATL::CRBMultiMap<k_t, m_t> rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( ::test_init_atl_multimap(rng, sample) );
|
||||
BOOST_CHECK( ::test_atl_map(rng, sample) );
|
||||
}
|
||||
|
||||
|
||||
// main test
|
||||
//
|
||||
|
||||
void test_atl()
|
||||
{
|
||||
|
||||
// ordinary ranges
|
||||
//
|
||||
{
|
||||
std::string sample("rebecca judy and mary whiteberry chat monchy");
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
::test_CAtlArray(sample);
|
||||
::test_CAtlList(sample);
|
||||
::test_CSimpleStringT(sample);
|
||||
::test_CFixedStringT<44>(sample);
|
||||
::test_CStringT(sample);
|
||||
::test_CStaticString(sample);
|
||||
#endif
|
||||
::test_CComBSTR(sample);
|
||||
::test_CSimpleArray(sample);
|
||||
::test_CSimpleMap(sample);
|
||||
::test_CSimpleValArray(sample);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
std::wstring sample(L"rebecca judy and mary whiteberry chat monchy");
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
::test_CAtlArray(sample);
|
||||
::test_CAtlList(sample);
|
||||
::test_CSimpleStringT(sample);
|
||||
::test_CFixedStringT<44>(sample);
|
||||
::test_CStringT(sample);
|
||||
::test_CStaticString(sample);
|
||||
#endif
|
||||
::test_CComBSTR(sample);
|
||||
::test_CSimpleArray(sample);
|
||||
::test_CSimpleMap(sample);
|
||||
::test_CSimpleValArray(sample);
|
||||
}
|
||||
|
||||
// pointer ranges
|
||||
//
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
{
|
||||
typedef ATL::CAutoPtr<int> ptr_t;
|
||||
ptr_t
|
||||
ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)),
|
||||
ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0));
|
||||
|
||||
ptr_t ptrs[8] = {
|
||||
ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7
|
||||
};
|
||||
|
||||
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
|
||||
::test_CAutoPtrArray<int>(workaround);
|
||||
}
|
||||
|
||||
{
|
||||
typedef ATL::CAutoPtr<int> ptr_t;
|
||||
ptr_t
|
||||
ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)),
|
||||
ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0));
|
||||
|
||||
ptr_t ptrs[8] = {
|
||||
ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7
|
||||
};
|
||||
|
||||
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
|
||||
::test_CAutoPtrList<int>(workaround);
|
||||
}
|
||||
|
||||
{
|
||||
typedef ATL::CHeapPtr<int> ptr_t;
|
||||
ptr_t ptrs[5]; {
|
||||
ptrs[0].AllocateBytes(sizeof(int));
|
||||
ptrs[1].AllocateBytes(sizeof(int));
|
||||
ptrs[2].AllocateBytes(sizeof(int));
|
||||
ptrs[3].AllocateBytes(sizeof(int));
|
||||
ptrs[4].AllocateBytes(sizeof(int));
|
||||
}
|
||||
|
||||
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+5);
|
||||
::test_CHeapPtrList<int>(workaround);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
typedef ATL::CComQIPtr<IDispatch> ptr_t;
|
||||
ptr_t ptrs[8];
|
||||
|
||||
boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
|
||||
::test_CInterfaceArray<IDispatch>(workaround);
|
||||
::test_CInterfaceList<IDispatch>(workaround);
|
||||
}
|
||||
#endif
|
||||
|
||||
// maps
|
||||
//
|
||||
{
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
std::map<int, std::string> sample; {
|
||||
sample[0] = "hello";
|
||||
sample[1] = "range";
|
||||
sample[2] = "atl";
|
||||
sample[3] = "mfc";
|
||||
sample[4] = "collections";
|
||||
}
|
||||
|
||||
::test_CAtlMap(sample);
|
||||
::test_CRBTree(sample);
|
||||
::test_CRBMap(sample);
|
||||
::test_CRBMultiMap(sample);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // test_atl
|
||||
|
||||
|
||||
#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("ATL Range Test Suite");
|
||||
test->add(BOOST_TEST_CASE(&test_atl));
|
||||
|
||||
(void)argc, (void)argv; // unused
|
||||
return test;
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
# pragma warn -8057 // unused argument argc/argv in Boost.Test
|
||||
#endif
|
||||
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <iostream>
|
||||
@ -79,12 +80,12 @@ void check_iterator_range()
|
||||
BOOST_CHECK( rr.equal( r ) );
|
||||
|
||||
rr = make_iterator_range( str.begin(), str.begin() + 5 );
|
||||
BOOST_CHECK( rr == "hello" );
|
||||
BOOST_CHECK( rr != "hell" );
|
||||
BOOST_CHECK( rr < "hello dude" );
|
||||
BOOST_CHECK( "hello" == rr );
|
||||
BOOST_CHECK( "hell" != rr );
|
||||
BOOST_CHECK( ! ("hello dude" < rr ) );
|
||||
BOOST_CHECK( rr == as_literal("hello") );
|
||||
BOOST_CHECK( rr != as_literal("hell") );
|
||||
BOOST_CHECK( rr < as_literal("hello dude") );
|
||||
BOOST_CHECK( as_literal("hello") == rr );
|
||||
BOOST_CHECK( as_literal("hell") != rr );
|
||||
BOOST_CHECK( ! (as_literal("hello dude") < rr ) );
|
||||
irange rrr = rr;
|
||||
BOOST_CHECK( rrr == rr );
|
||||
BOOST_CHECK( !( rrr != rr ) );
|
||||
@ -94,9 +95,10 @@ void check_iterator_range()
|
||||
BOOST_CHECK_EQUAL( cr.front(), 'h' );
|
||||
BOOST_CHECK_EQUAL( cr.back(), 'd' );
|
||||
BOOST_CHECK_EQUAL( cr[1], 'e' );
|
||||
BOOST_CHECK_EQUAL( cr(1), 'e' );
|
||||
|
||||
rrr = make_iterator_range( str, 1, -1 );
|
||||
BOOST_CHECK( rrr == "ello worl" );
|
||||
BOOST_CHECK( rrr == as_literal("ello worl") );
|
||||
rrr = make_iterator_range( rrr, -1, 1 );
|
||||
BOOST_CHECK( rrr == str );
|
||||
|
||||
|
787
test/mfc.cpp
787
test/mfc.cpp
@ -1,86 +1,743 @@
|
||||
// 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/
|
||||
// Boost.Range MFC Extension
|
||||
//
|
||||
// Copyright Shunsuke Sogame 2005-2006.
|
||||
// Distributed under 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)
|
||||
|
||||
#define _MSL_USING_NAMESPACE 1
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <afx.h> // must be here
|
||||
|
||||
#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 <pstade/vodka/drink.hpp>
|
||||
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
|
||||
#define _ATL_NO_AUTOMATIC_NAMESPACE
|
||||
|
||||
#define BOOST_LIB_NAME boost_test_exec_monitor
|
||||
#include <boost/config/auto_link.hpp>
|
||||
|
||||
#define BOOST_RANGE_DETAIL_MICROSOFT_TEST
|
||||
#include <boost/range/mfc.hpp> // can be placed first
|
||||
|
||||
|
||||
void check_mfc()
|
||||
#include <map>
|
||||
#include <boost/concept_check.hpp>
|
||||
// #include <boost/foreach.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
|
||||
#include <afx.h>
|
||||
#include <afxcoll.h>
|
||||
#include <afxtempl.h>
|
||||
|
||||
#if !(_ATL_VER < 0x0700)
|
||||
#include <cstringt.h>
|
||||
#include <atlsimpstr.h>
|
||||
#include <atlstr.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace brdm = boost::range_detail_microsoft;
|
||||
|
||||
|
||||
// helpers
|
||||
//
|
||||
|
||||
template< class MfcMapT, class MapT >
|
||||
bool test_mfc_map(MfcMapT& map, const MapT& sample)
|
||||
{
|
||||
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 ) );
|
||||
|
||||
typedef typename boost::range_iterator<MfcMapT>::type iter_t;
|
||||
typedef typename boost::range_const_iterator<MapT>::type siter_t;
|
||||
|
||||
bool result = true;
|
||||
|
||||
result = result && (boost::distance(map) == boost::distance(sample));
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
{
|
||||
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
|
||||
result = result && brdm::test_find_key_and_mapped(sample, *it);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
|
||||
result = result && (map[it->first] == it->second);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template< class MfcMapT, class MapT >
|
||||
bool test_mfc_cpair_map(MfcMapT& map, const MapT& sample)
|
||||
{
|
||||
typedef typename boost::range_iterator<MfcMapT>::type iter_t;
|
||||
typedef typename boost::range_const_iterator<MapT>::type siter_t;
|
||||
|
||||
bool result = true;
|
||||
|
||||
result = result && (boost::distance(map) == boost::distance(sample));
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
{
|
||||
for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
|
||||
result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->key, it->value));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
|
||||
result = result && (map[it->first] == it->second);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// arrays
|
||||
//
|
||||
template< class Range >
|
||||
void test_CByteArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CByteArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, BYTE *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, BYTE const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CDWordArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CDWordArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, DWORD *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, DWORD const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CObArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CObArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, brdm::mfc_ptr_array_iterator<rng_t, ::CObject *> >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, brdm::mfc_ptr_array_iterator<const rng_t, const ::CObject *> >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CPtrArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CPtrArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, brdm::mfc_ptr_array_iterator<rng_t, void *> >::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, brdm::mfc_ptr_array_iterator<const rng_t, const void *> >::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CStringArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CStringArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, ::CString *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, ::CString const *>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CUIntArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CUIntArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, UINT *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, UINT const *>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CWordArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CWordArray rng_t;
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, WORD *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, WORD const *>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
void test_CObList(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CObList rng_t;
|
||||
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, ::CObject *> >::value ));
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CObject const *> >::value ));
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CObject const * const, ::CObject const * const> >::value ));
|
||||
#endif
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CPtrList(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CPtrList rng_t;
|
||||
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, void *> >::value ));
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, void const *> >::value ));
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, void const * const, void const * const> >::value ));
|
||||
#endif
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CStringList(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CStringList rng_t;
|
||||
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, ::CString> >::value ));
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CString const> >::value ));
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, ::CString const, ::CString const> >::value ));
|
||||
#endif
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapPtrToWord(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapPtrToWord rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapPtrToPtr(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapPtrToPtr rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapStringToOb(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapStringToOb rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapStringToPtr(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapStringToPtr rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapStringToString(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapStringToString rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
BOOST_CHECK( ::test_mfc_cpair_map(rng, sample) );
|
||||
#endif
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapWordToOb(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapWordToOb rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMapWordToPtr(const MapT& sample)
|
||||
{
|
||||
typedef ::CMapWordToPtr rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// templates
|
||||
//
|
||||
|
||||
template< class Range >
|
||||
void test_CArray(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CArray<val_t, const val_t&> rng_t; // An old MFC needs the second template argument.
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, val_t const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_array(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class Range >
|
||||
void test_CList(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CList<val_t, const val_t&> rng_t;
|
||||
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t, val_t> >::value ));
|
||||
#if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, val_t const> >::value ));
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter < rng_t, brdm::list_iterator<rng_t const, val_t const, val_t const> >::value ));
|
||||
#endif
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_list(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_bidirectional(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
template< class MapT >
|
||||
void test_CMap(const MapT& sample)
|
||||
{
|
||||
typedef typename MapT::key_type k_t;
|
||||
typedef typename MapT::mapped_type m_t;
|
||||
|
||||
typedef ::CMap<k_t, const k_t&, m_t, const m_t&> rng_t;
|
||||
|
||||
rng_t rng;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
BOOST_CHECK( brdm::test_init_map(rng, sample) );
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
BOOST_CHECK( ::test_mfc_cpair_map(rng, sample) );
|
||||
#endif
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
void test_CTypedPtrArray()
|
||||
{
|
||||
typedef ::CTypedPtrArray< ::CPtrArray, int * > rng_t;
|
||||
boost::function_requires< boost::RandomAccessRangeConcept<rng_t> >();
|
||||
|
||||
rng_t rng;
|
||||
int o1, o2, o3, o4, o5;
|
||||
int *data[] = { &o1, &o2, &o3, &o4, &o5 };
|
||||
BOOST_CHECK( brdm::test_init_array(rng, boost::make_iterator_range(data, data+5)) );
|
||||
|
||||
BOOST_CHECK( *(boost::begin(rng) + 2) == &o3 );
|
||||
BOOST_CHECK( *(boost::end(rng) - 1) == &o5 );
|
||||
|
||||
// BOOST_CHECK( brdm::test_random_access(rng) ); this range is not mutable
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
void test_CTypedPtrList()
|
||||
{
|
||||
typedef ::CTypedPtrList< ::CObList, ::CObList * > rng_t;
|
||||
boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
|
||||
|
||||
rng_t rng;
|
||||
|
||||
::CObList o1, o2, o3, o4, o5;
|
||||
::CObList *data[] = { &o1, &o2, &o3, &o4, &o5 };
|
||||
BOOST_CHECK( brdm::test_init_list(rng, data) );
|
||||
|
||||
boost::range_iterator<rng_t>::type it = boost::begin(rng);
|
||||
std::advance(it, 1);
|
||||
BOOST_CHECK( *it == &o2 );
|
||||
std::advance(it, 2);
|
||||
BOOST_CHECK( *it == &o4 );
|
||||
|
||||
// BOOST_CHECK( brdm::test_bidirectional(rng) ); this range is not mutable
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
void test_CTypedPtrMap()
|
||||
{
|
||||
typedef ::CTypedPtrMap< ::CMapStringToPtr, ::CString, int *> rng_t;
|
||||
boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
|
||||
|
||||
rng_t rng;
|
||||
::CString o0(_T('a')), o1(_T('c')), o2(_T('f')), o3(_T('q')), o4(_T('g'));
|
||||
int d0, d1, d2, d3, d4;
|
||||
std::map< ::CString, int * > data;
|
||||
data[o0] = &d0, data[o1] = &d1, data[o2] = &d2, data[o3] = &d3, data[o4] = &d4;
|
||||
|
||||
BOOST_CHECK( brdm::test_init_map(rng, data) );
|
||||
BOOST_CHECK( ::test_mfc_map(rng, data) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
|
||||
|
||||
template< class Range >
|
||||
void test_CString(const Range& sample)
|
||||
{
|
||||
typedef typename boost::range_value<Range>::type val_t;
|
||||
|
||||
typedef ::CString rng_t; // An old MFC needs the second template argument.
|
||||
BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, TCHAR *>::value ));
|
||||
BOOST_STATIC_ASSERT(( brdm::test_const_iter <rng_t, TCHAR const*>::value ));
|
||||
|
||||
rng_t rng;
|
||||
BOOST_CHECK( brdm::test_init_string(rng, sample) );
|
||||
BOOST_CHECK( brdm::test_random_access(rng) );
|
||||
BOOST_CHECK( brdm::test_emptiness(rng) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct CPerson
|
||||
{
|
||||
void hello_range() { };
|
||||
};
|
||||
|
||||
|
||||
void test_mfc()
|
||||
{
|
||||
#if 0
|
||||
// overview
|
||||
//
|
||||
{
|
||||
CTypedPtrArray<CPtrArray, CList<CString> *> myArray;
|
||||
// ...
|
||||
BOOST_FOREACH (CList<CString> *theList, myArray)
|
||||
{
|
||||
BOOST_FOREACH (CString& str, *theList)
|
||||
{
|
||||
boost::to_upper(str);
|
||||
std::sort(boost::begin(str), boost::end(str));
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// arrays
|
||||
//
|
||||
{
|
||||
BYTE data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
|
||||
|
||||
::test_CByteArray(boost::make_iterator_range(data, data+22));
|
||||
}
|
||||
|
||||
{
|
||||
DWORD data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
|
||||
|
||||
test_CDWordArray(boost::make_iterator_range(data, data+22));
|
||||
}
|
||||
|
||||
{
|
||||
::CObArray o1, o2, o3, o4, o5;
|
||||
::CObject *data[] = { &o1, &o2, &o3, &o4, &o5 };
|
||||
|
||||
::test_CObArray(boost::make_iterator_range(data, data+5));
|
||||
}
|
||||
|
||||
{
|
||||
::CPtrArray o1, o2, o3, o4, o5;
|
||||
void *data[] = { &o1, &o2, &o3, &o4, &o5 };
|
||||
|
||||
::test_CPtrArray(boost::make_iterator_range(data, data+5));
|
||||
}
|
||||
|
||||
{
|
||||
::CString data[] = {
|
||||
::CString(_T('0')), ::CString(_T('1')), ::CString(_T('2')), ::CString(_T('3')),
|
||||
::CString(_T('4')), ::CString(_T('5')), ::CString(_T('6')), ::CString(_T('7'))
|
||||
};
|
||||
|
||||
::test_CStringArray(boost::make_iterator_range(data, data+8));
|
||||
}
|
||||
|
||||
{
|
||||
::CUIntArray rng;
|
||||
UINT data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
|
||||
|
||||
::test_CUIntArray(boost::make_iterator_range(data, data+22));
|
||||
}
|
||||
|
||||
{
|
||||
::CWordArray rng;
|
||||
WORD data[] = { 4,5,1,3,5,12,3,1,3,1,6,1,3,60,1,1,5,1,3,1,10 };
|
||||
|
||||
::test_CWordArray(boost::make_iterator_range(data, data+22));
|
||||
}
|
||||
|
||||
|
||||
// lists
|
||||
//
|
||||
{
|
||||
::CObList rng;
|
||||
::CObList o1, o2, o3, o4, o5;
|
||||
::CObject *data[] = { &o1, &o2, &o3, &o4, &o5 };
|
||||
|
||||
::test_CObList(boost::make_iterator_range(data, data+5));
|
||||
}
|
||||
|
||||
{
|
||||
::CPtrList rng;
|
||||
::CPtrList o1, o2, o3, o4, o5;
|
||||
void *data[] = { &o1, &o2, &o3, &o4, &o5 };
|
||||
|
||||
::test_CPtrList(boost::make_iterator_range(data, data+5));
|
||||
}
|
||||
|
||||
{
|
||||
::CString data[] = {
|
||||
::CString(_T('0')), ::CString(_T('1')), ::CString(_T('2')), ::CString(_T('3')),
|
||||
::CString(_T('4')), ::CString(_T('5')), ::CString(_T('6')), ::CString(_T('7'))
|
||||
};
|
||||
|
||||
::test_CStringList(boost::make_iterator_range(data, data+8));
|
||||
}
|
||||
|
||||
|
||||
// maps
|
||||
//
|
||||
{
|
||||
std::map<void *, WORD> data;
|
||||
int o0, o1, o2, o3, o4;
|
||||
data[&o0] = 15, data[&o1] = 14, data[&o2] = 3, data[&o3] = 6, data[&o4] = 1;
|
||||
|
||||
::test_CMapPtrToWord(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map<void *, void*> data;
|
||||
int o0, o1, o2, o3, o4;
|
||||
data[&o0] = &o3, data[&o1] = &o2, data[&o2] = &o1, data[&o3] = &o0, data[&o4] = &o4;
|
||||
|
||||
::test_CMapPtrToPtr(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map< ::CString, CObject * > data;
|
||||
CObArray o0, o1, o2, o3, o4;
|
||||
data[ ::CString('0') ] = &o0, data[ ::CString('1') ] = &o1, data[ ::CString('2') ] = &o2,
|
||||
data[ ::CString('3') ] = &o3, data[ ::CString('4') ] = &o4;
|
||||
|
||||
::test_CMapStringToOb(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map< ::CString, void * > data;
|
||||
CObArray o0, o1, o2, o3, o4;
|
||||
data[ ::CString('0') ] = &o0, data[ ::CString('1') ] = &o1, data[ ::CString('2') ] = &o2,
|
||||
data[ ::CString('3') ] = &o3, data[ ::CString('4') ] = &o4;
|
||||
|
||||
::test_CMapStringToPtr(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map< ::CString, ::CString > data;
|
||||
CString o0('a'), o1('b'), o2('c'), o3('d'), o4('e');
|
||||
data[ ::CString('0') ] = o0, data[ ::CString('1') ] = o1, data[ ::CString('2') ] = o2,
|
||||
data[ ::CString('3') ] = o3, data[ ::CString('4') ] = o4;
|
||||
|
||||
::test_CMapStringToString(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map< WORD, CObject * > data;
|
||||
::CDWordArray o0, o1, o2, o3, o4;
|
||||
data[21] = &o3, data[52] = &o2, data[12] = &o1, data[76] = &o0, data[54] = &o4;
|
||||
|
||||
::test_CMapWordToOb(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map< WORD, void * > data;
|
||||
::CDWordArray o0, o1, o2, o3, o4;
|
||||
data[21] = &o3, data[52] = &o2, data[12] = &o1, data[76] = &o0, data[54] = &o4;
|
||||
|
||||
::test_CMapWordToPtr(data);
|
||||
}
|
||||
|
||||
// templates
|
||||
//
|
||||
{
|
||||
std::string data("0987654321qwertyuiop");
|
||||
::test_CArray(data);
|
||||
::test_CList(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::wstring data(L"asdfghjklzxcvbnm");
|
||||
::test_CArray(data);
|
||||
::test_CList(data);
|
||||
}
|
||||
|
||||
{
|
||||
std::map< int, std::string > data;
|
||||
data[0] = "abcde", data[1] = "ajfie", data[2] = "lij", data[3] = "abc", data[4] = "ioiu";
|
||||
|
||||
::test_CMap(data);
|
||||
}
|
||||
|
||||
|
||||
// typed
|
||||
//
|
||||
{
|
||||
::test_CTypedPtrArray();
|
||||
::test_CTypedPtrList();
|
||||
::test_CTypedPtrMap();
|
||||
}
|
||||
|
||||
|
||||
// strings
|
||||
//
|
||||
#if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
|
||||
{
|
||||
std::string data("123456789 abcdefghijklmn");
|
||||
::test_CString(data);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} // test_mfc
|
||||
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
|
||||
test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
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 ) );
|
||||
test_suite *test = BOOST_TEST_SUITE("MFC Range Test Suite");
|
||||
test->add(BOOST_TEST_CASE(&test_mfc));
|
||||
|
||||
(void)argc, (void)argv; // unused
|
||||
return test;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -33,28 +33,28 @@ template< class T >
|
||||
inline BOOST_DEDUCED_TYPENAME boost::range_iterator<T>::type
|
||||
str_begin( T& r )
|
||||
{
|
||||
return boost::begin( as_literal(r) );
|
||||
return boost::begin( boost::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) );
|
||||
return boost::end( boost::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) );
|
||||
return boost::size( boost::as_literal(r) );
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline bool
|
||||
str_empty( T& r )
|
||||
{
|
||||
return boost::empty( as_literal(r) );
|
||||
return boost::empty( boost::as_literal(r) );
|
||||
}
|
||||
|
||||
template< typename Container, typename T >
|
||||
|
@ -17,6 +17,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/range/sub_range.hpp>
|
||||
#include <boost/range/as_literal.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -110,12 +111,12 @@ void check_sub_range()
|
||||
BOOST_CHECK( rr.equal( r ) );
|
||||
|
||||
rr = make_iterator_range( str.begin(), str.begin() + 5 );
|
||||
BOOST_CHECK( rr == "hello" );
|
||||
BOOST_CHECK( rr != "hell" );
|
||||
BOOST_CHECK( rr < "hello dude" );
|
||||
BOOST_CHECK( "hello" == rr );
|
||||
BOOST_CHECK( "hell" != rr );
|
||||
BOOST_CHECK( ! ("hello dude" < rr ) );
|
||||
BOOST_CHECK( rr == as_literal("hello") );
|
||||
BOOST_CHECK( rr != as_literal("hell") );
|
||||
BOOST_CHECK( rr < as_literal("hello dude") );
|
||||
BOOST_CHECK( as_literal("hello") == rr );
|
||||
BOOST_CHECK( as_literal("hell") != rr );
|
||||
BOOST_CHECK( ! (as_literal("hello dude") < rr ) );
|
||||
|
||||
irange rrr = rr;
|
||||
BOOST_CHECK( rrr == rr );
|
||||
@ -126,15 +127,16 @@ void check_sub_range()
|
||||
BOOST_CHECK_EQUAL( cr.front(), 'h' );
|
||||
BOOST_CHECK_EQUAL( cr.back(), 'd' );
|
||||
BOOST_CHECK_EQUAL( cr[1], 'e' );
|
||||
BOOST_CHECK_EQUAL( cr(1), 'e' );
|
||||
|
||||
rrr = make_iterator_range( str, 1, -1 );
|
||||
BOOST_CHECK( rrr == "ello worl" );
|
||||
BOOST_CHECK( rrr == as_literal("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" );
|
||||
BOOST_CHECK( rrr == as_literal("HEllo worlD") );
|
||||
}
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
Reference in New Issue
Block a user