mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 02:44:10 +00:00
Merged 52463
[SVN r55485]
This commit is contained in:
parent
61755605af
commit
d5291d08b8
@ -132,18 +132,18 @@
|
||||
class MyInt
|
||||
: boost::operators<MyInt>
|
||||
{
|
||||
bool operator<(const MyInt& x) const;
|
||||
bool operator<(const MyInt& x) const;
|
||||
bool operator==(const MyInt& x) const;
|
||||
MyInt& operator+=(const MyInt& x);
|
||||
MyInt& operator-=(const MyInt& x);
|
||||
MyInt& operator*=(const MyInt& x);
|
||||
MyInt& operator/=(const MyInt& x);
|
||||
MyInt& operator%=(const MyInt& x);
|
||||
MyInt& operator|=(const MyInt& x);
|
||||
MyInt& operator&=(const MyInt& x);
|
||||
MyInt& operator^=(const MyInt& x);
|
||||
MyInt& operator++();
|
||||
MyInt& operator--();
|
||||
MyInt& operator+=(const MyInt& x);
|
||||
MyInt& operator-=(const MyInt& x);
|
||||
MyInt& operator*=(const MyInt& x);
|
||||
MyInt& operator/=(const MyInt& x);
|
||||
MyInt& operator%=(const MyInt& x);
|
||||
MyInt& operator|=(const MyInt& x);
|
||||
MyInt& operator&=(const MyInt& x);
|
||||
MyInt& operator^=(const MyInt& x);
|
||||
MyInt& operator++();
|
||||
MyInt& operator--();
|
||||
};
|
||||
</pre>
|
||||
</blockquote>
|
||||
@ -345,7 +345,7 @@ class MyInt
|
||||
</ul>
|
||||
|
||||
<p>As Daniel Krügler pointed out, this technique violates 14.6.5/2
|
||||
and is thus non-portable. The reasoning is, that the operators injected
|
||||
and is thus non-portable. The reasoning is, that the operators injected
|
||||
by the instantiation of e.g.
|
||||
<code>less_than_comparable<myclass></code> can not be found
|
||||
by ADL according to the rules given by 3.4.2/2, since myclass is
|
||||
@ -445,6 +445,9 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
optional template parameter <code>B</code>, which is not shown, for the
|
||||
<a href="#chaining">base class chaining</a> technique.</p>
|
||||
|
||||
<p>The primary operand type <code>T</code> needs to be of class type,
|
||||
built-in types are not supported.</p>
|
||||
|
||||
<table cellpadding="5" border="1" align="center">
|
||||
<caption>
|
||||
Simple Arithmetic Operator Template Classes
|
||||
@ -917,7 +920,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
created, <code>operator+=</code> is called on it and it is copied to the
|
||||
function return value (which is another unnamed object of type
|
||||
<code>T</code>). The standard doesn't generally allow the intermediate
|
||||
object to be optimized away:
|
||||
object to be optimized away:
|
||||
|
||||
<blockquote>
|
||||
3.7.2/2: Automatic storage duration<br>
|
||||
@ -928,7 +931,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
unused, except that a class object or its copy may be eliminated as
|
||||
specified in 12.8.
|
||||
</blockquote>
|
||||
The reference to 12.8 is important for us:
|
||||
The reference to 12.8 is important for us:
|
||||
|
||||
<blockquote>
|
||||
12.8/15: Copying class objects<br>
|
||||
@ -942,7 +945,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
</blockquote>
|
||||
This optimization is known as the named return value optimization (NRVO),
|
||||
which leads us to the following implementation for
|
||||
<code>operator+</code>:
|
||||
<code>operator+</code>:
|
||||
<pre>
|
||||
T operator+( const T& lhs, const T& rhs )
|
||||
{
|
||||
@ -956,7 +959,7 @@ T operator+( const T& lhs, const T& rhs )
|
||||
even implement it in an incorrect way which makes it useless here.
|
||||
Without the NRVO, the NRVO-friendly code is no worse than the original
|
||||
code showed above, but there is another possible implementation, which
|
||||
has some very special properties:
|
||||
has some very special properties:
|
||||
<pre>
|
||||
T operator+( T lhs, const T& rhs )
|
||||
{
|
||||
@ -982,7 +985,7 @@ T operator+( T lhs, const T& rhs )
|
||||
will force the NRVO-friendly implementation to be used even for compilers
|
||||
that don't implement the NRVO. <br>
|
||||
<br>
|
||||
|
||||
|
||||
<h3><a name="grpd_oprs">Grouped Arithmetic Operators</a></h3>
|
||||
|
||||
<p>The following templates provide common groups of related operations.
|
||||
@ -1864,7 +1867,7 @@ T operator+( T lhs, const T& rhs )
|
||||
V, D, P, R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href="#input_iteratable">input_iteratable<T,
|
||||
@ -1878,7 +1881,7 @@ T operator+( T lhs, const T& rhs )
|
||||
"output_iterator_helper">output_iterator_helper<T></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
@ -1894,7 +1897,7 @@ T operator+( T lhs, const T& rhs )
|
||||
R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href="#forward_iteratable">forward_iteratable<T,
|
||||
@ -1909,7 +1912,7 @@ T operator+( T lhs, const T& rhs )
|
||||
V, D, P, R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
@ -1925,7 +1928,7 @@ T operator+( T lhs, const T& rhs )
|
||||
V, D, P, R></a></code></td>
|
||||
|
||||
<td>
|
||||
Supports the operations and has the requirements of
|
||||
Supports the operations and has the requirements of
|
||||
|
||||
<ul>
|
||||
<li><code><a href=
|
||||
@ -1976,8 +1979,8 @@ struct function_output_iterator
|
||||
template<typename T>
|
||||
function_output_iterator& operator=(T const& value)
|
||||
{
|
||||
this->func(value);
|
||||
return *this;
|
||||
this->func(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -2130,8 +2133,8 @@ public:
|
||||
<p>Revised: 7 Aug 2008</p>
|
||||
|
||||
<p>Copyright © Beman Dawes, David Abrahams, 1999-2001.</p>
|
||||
<p>Copyright © Daniel Frey, 2002-2008.</p>
|
||||
<p>Use, modification, and distribution is subject to the Boost Software
|
||||
<p>Copyright © Daniel Frey, 2002-2009.</p>
|
||||
<p>Use, modification, and distribution is subject to the Boost Software
|
||||
License, Version 1.0. (See accompanying file
|
||||
<a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">
|
||||
|
Loading…
x
Reference in New Issue
Block a user