Join ralf_grosse_kunstleve with HEAD

[SVN r9444]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2001-03-05 20:01:01 +00:00
parent a9adec170a
commit 7ea60a96f8
3 changed files with 50 additions and 40 deletions

View File

@ -34,9 +34,9 @@ specialization or member templates, no benefit will occur from
using call_traits: the call_traits defined types will always be using call_traits: the call_traits defined types will always be
the same as the existing practice in this case. In addition if the same as the existing practice in this case. In addition if
only member templates and not partial template specialisation is only member templates and not partial template specialisation is
support by the compiler (for example Visual C++ 6) then call_traits support by the compiler (for example Visual C++ 6) then
can not be used with array types (although it can be used to call_traits can not be used with array types (although it can be
solve the reference to reference problem).</p> used to solve the reference to reference problem).</p>
<table border="0" cellpadding="7" cellspacing="1" width="797"> <table border="0" cellpadding="7" cellspacing="1" width="797">
<tr> <tr>
@ -79,7 +79,8 @@ solve the reference to reference problem).</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td valign="top" width="17%"><p align="center">const T&amp;<br> <td valign="top" width="17%"><p align="center">const
T&amp;<br>
(return value)</p> (return value)</p>
</td> </td>
<td valign="top" width="35%"><p align="center"><code>call_traits&lt;T&gt;::const_reference</code></p> <td valign="top" width="35%"><p align="center"><code>call_traits&lt;T&gt;::const_reference</code></p>
@ -91,7 +92,8 @@ solve the reference to reference problem).</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td valign="top" width="17%"><p align="center">const T&amp;<br> <td valign="top" width="17%"><p align="center">const
T&amp;<br>
(function parameter)</p> (function parameter)</p>
</td> </td>
<td valign="top" width="35%"><p align="center"><code>call_traits&lt;T&gt;::param_type</code></p> <td valign="top" width="35%"><p align="center"><code>call_traits&lt;T&gt;::param_type</code></p>
@ -332,8 +334,8 @@ possible:</p>
<p>The following table shows the effect that call_traits has on <p>The following table shows the effect that call_traits has on
various types, the table assumes that the compiler supports various types, the table assumes that the compiler supports
partial specialization: if it doesn't then all types behave in partial specialization: if it doesn't then all types behave in
the same way as the entry for &quot;myclass&quot;, and call_traits the same way as the entry for &quot;myclass&quot;, and
can not be used with reference or array types.</p> call_traits can not be used with reference or array types.</p>
<table border="0" cellpadding="7" cellspacing="1" width="766"> <table border="0" cellpadding="7" cellspacing="1" width="766">
<tr> <tr>
@ -388,7 +390,8 @@ can not be used with reference or array types.</p>
</td> </td>
<td valign="top" width="17%"><p align="center">int&amp;</p> <td valign="top" width="17%"><p align="center">int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">const int&amp;</p> <td valign="top" width="17%"><p align="center">const
int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">int const</p> <td valign="top" width="17%"><p align="center">int const</p>
</td> </td>
@ -420,7 +423,8 @@ can not be used with reference or array types.</p>
</td> </td>
<td valign="top" width="17%"><p align="center">int&amp;</p> <td valign="top" width="17%"><p align="center">int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">const int&amp;</p> <td valign="top" width="17%"><p align="center">const
int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">int&amp;</p> <td valign="top" width="17%"><p align="center">int&amp;</p>
</td> </td>
@ -432,13 +436,17 @@ can not be used with reference or array types.</p>
<td valign="top" width="17%" bgcolor="#C0C0C0"><p <td valign="top" width="17%" bgcolor="#C0C0C0"><p
align="center">const int&amp;</p> align="center">const int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">const int&amp;</p> <td valign="top" width="17%"><p align="center">const
int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">const int&amp;</p> <td valign="top" width="17%"><p align="center">const
int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">const int&amp;</p> <td valign="top" width="17%"><p align="center">const
int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">const int&amp;</p> <td valign="top" width="17%"><p align="center">const
int&amp;</p>
</td> </td>
<td valign="top" width="17%"><p align="center">All <td valign="top" width="17%"><p align="center">All
constant-references.</p> constant-references.</p>
@ -486,8 +494,8 @@ can not be used with reference or array types.</p>
<p>The following class is a trivial class that stores some type T <p>The following class is a trivial class that stores some type T
by value (see the <a href="call_traits_test.cpp">call_traits_test.cpp</a> by value (see the <a href="call_traits_test.cpp">call_traits_test.cpp</a>
file), the aim is to illustrate how each of the available call_traits file), the aim is to illustrate how each of the available
typedefs may be used:</p> call_traits typedefs may be used:</p>
<pre>template &lt;class T&gt; <pre>template &lt;class T&gt;
struct contained struct contained
@ -523,14 +531,14 @@ problem):</h4>
<pre>template &lt;class Operation&gt; <pre>template &lt;class Operation&gt;
class binder1st : class binder1st :
public unary_function&lt;Operation::second_argument_type, Operation::result_type&gt; public unary_function&lt;typename Operation::second_argument_type, typename Operation::result_type&gt;
{ {
protected: protected:
Operation op; Operation op;
Operation::first_argument_type value; typename Operation::first_argument_type value;
public: public:
binder1st(const Operation&amp; x, const Operation::first_argument_type&amp; y); binder1st(const Operation&amp; x, const typename Operation::first_argument_type&amp; y);
Operation::result_type operator()(const Operation::second_argument_type&amp; x) const; typename Operation::result_type operator()(const typename Operation::second_argument_type&amp; x) const;
}; </pre> }; </pre>
<p>Now consider what happens in the relatively common case that <p>Now consider what happens in the relatively common case that
@ -541,7 +549,7 @@ reference to a reference as an argument, and that is not
currently legal. The solution here is to modify <code>operator()</code> currently legal. The solution here is to modify <code>operator()</code>
to use call_traits:</p> to use call_traits:</p>
<pre>Operation::result_type operator()(call_traits&lt;Operation::second_argument_type&gt;::param_type x) const;</pre> <pre>typename Operation::result_type operator()(typename call_traits&lt;typename Operation::second_argument_type&gt;::param_type x) const;</pre>
<p>Now in the case that <code>Operation::second_argument_type</code> <p>Now in the case that <code>Operation::second_argument_type</code>
is a reference type, the argument is passed as a reference, and is a reference type, the argument is passed as a reference, and
@ -575,9 +583,9 @@ std::pair&lt;
degraded to pointers if the deduced types are arrays, similar degraded to pointers if the deduced types are arrays, similar
situations occur in the standard binders and adapters: in situations occur in the standard binders and adapters: in
principle in any function that &quot;wraps&quot; a temporary principle in any function that &quot;wraps&quot; a temporary
whose type is deduced. Note that the function arguments to make_pair whose type is deduced. Note that the function arguments to
are not expressed in terms of call_traits: doing so would prevent make_pair are not expressed in terms of call_traits: doing so
template argument deduction from functioning.</p> would prevent template argument deduction from functioning.</p>
<h4><a name="ex4"></a>Example 4 (optimising fill):</h4> <h4><a name="ex4"></a>Example 4 (optimising fill):</h4>
@ -666,10 +674,10 @@ be any worse than existing practice.</p>
<p>Pointers follow the same rational as small built-in types.</p> <p>Pointers follow the same rational as small built-in types.</p>
<p>For reference types the rational follows <a href="#refs">Example <p>For reference types the rational follows <a href="#refs">Example
2</a> - references to references are not allowed, so the call_traits 2</a> - references to references are not allowed, so the
members must be defined such that these problems do not occur. call_traits members must be defined such that these problems do
There is a proposal to modify the language such that &quot;a not occur. There is a proposal to modify the language such that
reference to a reference is a reference&quot; (issue #106, &quot;a reference to a reference is a reference&quot; (issue #106,
submitted by Bjarne Stroustrup), call_traits&lt;T&gt;::value_type submitted by Bjarne Stroustrup), call_traits&lt;T&gt;::value_type
and call_traits&lt;T&gt;::param_type both provide the same effect and call_traits&lt;T&gt;::param_type both provide the same effect
as that proposal, without the need for a language change (in as that proposal, without the need for a language change (in
@ -687,11 +695,11 @@ struct A
void foo(T t); void foo(T t);
};</pre> };</pre>
<p><font face="Times New Roman">In this case if we instantiate A&lt;int[2]&gt; <p><font face="Times New Roman">In this case if we instantiate
then the declared type of the parameter passed to member function A&lt;int[2]&gt; then the declared type of the parameter passed to
foo is int[2], but it's actual type is const int*, if we try to member function foo is int[2], but it's actual type is const int*,
use the type T within the function body, then there is a strong if we try to use the type T within the function body, then there
likelyhood that our code will not compile:</font></p> is a strong likelyhood that our code will not compile:</font></p>
<pre>template &lt;class T&gt; <pre>template &lt;class T&gt;
void A&lt;T&gt;::foo(T t) void A&lt;T&gt;::foo(T t)
@ -706,13 +714,13 @@ declared type:</p>
<pre>template &lt;class T&gt; <pre>template &lt;class T&gt;
struct A struct A
{ {
void foo(call_traits&lt;T&gt;::value_type t); void foo(typename call_traits&lt;T&gt;::value_type t);
}; };
template &lt;class T&gt; template &lt;class T&gt;
void A&lt;T&gt;::foo(call_traits&lt;T&gt;::value_type t) void A&lt;T&gt;::foo(typename call_traits&lt;T&gt;::value_type t)
{ {
call_traits&lt;T&gt;::value_type dup(t); // OK even if T is an array type. typename call_traits&lt;T&gt;::value_type dup(t); // OK even if T is an array type.
}</pre> }</pre>
<p>For value_type (return by value), again only a pointer may be <p>For value_type (return by value), again only a pointer may be

View File

@ -15,6 +15,8 @@
// See http://www.boost.org for most recent version including documentation. // See http://www.boost.org for most recent version including documentation.
// Revision History // Revision History
// 11 Feb 01 Fixed bugs in the iterator helpers which prevented explicitly
// supplied arguments from actually being used (Dave Abrahams)
// 04 Jul 00 Fixed NO_OPERATORS_IN_NAMESPACE bugs, major cleanup and // 04 Jul 00 Fixed NO_OPERATORS_IN_NAMESPACE bugs, major cleanup and
// refactoring of compiler workarounds, additional documentation // refactoring of compiler workarounds, additional documentation
// (Alexy Gurtovoy and Mark Rodgers with some help and prompting from // (Alexy Gurtovoy and Mark Rodgers with some help and prompting from
@ -514,7 +516,7 @@ struct forward_iterator_helper
: equality_comparable<T : equality_comparable<T
, incrementable<T , incrementable<T
, dereferenceable<T,P , dereferenceable<T,P
, boost::iterator<std::forward_iterator_tag, V, D , boost::iterator<std::forward_iterator_tag,V,D,P,R
> > > > {}; > > > > {};
template <class T, template <class T,
@ -527,7 +529,7 @@ struct bidirectional_iterator_helper
, incrementable<T , incrementable<T
, decrementable<T , decrementable<T
, dereferenceable<T,P , dereferenceable<T,P
, boost::iterator<std::bidirectional_iterator_tag, V, D , boost::iterator<std::bidirectional_iterator_tag,V,D,P,R
> > > > > {}; > > > > > {};
template <class T, template <class T,
@ -544,7 +546,7 @@ struct random_access_iterator_helper
, addable2<T,D , addable2<T,D
, subtractable2<T,D , subtractable2<T,D
, indexable<T,D,R , indexable<T,D,R
, boost::iterator<std::random_access_iterator_tag, V, D , boost::iterator<std::random_access_iterator_tag,V,D,P,R
> > > > > > > > > > > > > > > > > >
{ {
#ifndef __BORLANDC__ #ifndef __BORLANDC__

View File

@ -81,7 +81,7 @@ CodeWarrior 5.0, and Microsoft Visual C++ 6.0 sp 3.</p>
<pre>// inside one of your own headers ... <pre>// inside one of your own headers ...
#include &lt;boost/utility.hpp&gt; #include &lt;boost/utility.hpp&gt;
class ResourceLadenFileSystem : noncopyable { class ResourceLadenFileSystem : boost::noncopyable {
...</pre> ...</pre>
</blockquote> </blockquote>
@ -93,7 +93,7 @@ destructor declarations. He says &quot;Probably this concern is misplaced, becau
noncopyable will be used mostly for classes which own resources and thus have non-trivial destruction semantics.&quot;</p> noncopyable will be used mostly for classes which own resources and thus have non-trivial destruction semantics.&quot;</p>
<hr> <hr>
<p>Revised&nbsp; <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan <p>Revised&nbsp; <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan
-->28 September, 2000<!--webbot bot="Timestamp" endspan i-checksum="39343" -->16 February, 2001<!--webbot bot="Timestamp" endspan i-checksum="40407"
--> -->
</p> </p>
<p><EFBFBD> Copyright boost.org 1999. Permission to copy, use, modify, sell and <p><EFBFBD> Copyright boost.org 1999. Permission to copy, use, modify, sell and