|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56997 - sandbox/committee/rvalue_ref
From: dave_at_[hidden]
Date: 2009-10-19 12:22:16
Author: dave
Date: 2009-10-19 12:22:15 EDT (Mon, 19 Oct 2009)
New Revision: 56997
URL: http://svn.boost.org/trac/boost/changeset/56997
Log:
Added low-hanging fruit; make sure legacy_move is documented
Text files modified:
sandbox/committee/rvalue_ref/N2983-throwing-move.rst | 59 ++++++++++++++++++++++++++
sandbox/committee/rvalue_ref/N2983.html | 86 ++++++++++++++++++++++++++++++++-------
2 files changed, 127 insertions(+), 18 deletions(-)
Modified: sandbox/committee/rvalue_ref/N2983-throwing-move.rst
==============================================================================
--- sandbox/committee/rvalue_ref/N2983-throwing-move.rst (original)
+++ sandbox/committee/rvalue_ref/N2983-throwing-move.rst 2009-10-19 12:22:15 EDT (Mon, 19 Oct 2009)
@@ -250,6 +250,33 @@
in the standard. Standardizing ``throw(false)`` gives everyone access
to this optimization tool.
+Low-Hanging Fruit
+*****************
+
+There are a couple of additional features we think the committee
+should consider if this proposal is accepted.
+
+Implicit ``throw(false)`` for Destructors
+=========================================
+
+So few destructors can throw exceptions that the default
+exception-specification for destructors could be changed from nothing
+(i.e. ``throw(true)``) to ``throw(false)`` with only a tiny amount of code
+breakage. Such code is already very dangerous, and where used
+properly, ought to be a well-known âcaution areaâ that is reasonably
+easily migrated.
+
+operator ``may_throw(``\ *expression*\ ``)``
+============================================
+
+It seems that ``has_nothrow_``\ *xxx* traits are proliferating (and
+not just in this proposal). Once we have ``throw(``\
+*bool-constant-expr*\ ``)`` available to make the information
+available, it makes sense to generalize the traits into an operator
+similar to ``sizeof`` and ``typeof`` that can give us answers about
+*any* expression.
+
+
Proposed Changes to Standard Wording
************************************
@@ -310,8 +337,36 @@
throw ( type-id-listopt )
:ins:`throw(constant-expression)`
-20.6.2 Header <type_traits> synopsis [meta.type.synop]
-======================================================
+20.3 Utility components [utility]
+=================================
+
+Change Header ``<utility>`` synopsis as follows:
+
+.. parsed-literal::
+
+ // 20.3.2, forward/move:
+ template <class T> struct identity;
+ template <class T> T&& forward(typename identity<T>::type&&);
+ template <class T> typename remove_reference<T>::type&& move(T&&);
+ :ins:`template <class T> typename conditional<
+ !has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
+ T const&, T&&>::type legacy_move(T& x);`
+
+20.3.2 forward/move helpers [forward]
+=====================================
+
+Append the following:
+
+ .. parsed-literal::
+
+ :ins:`template <class T> typename conditional<
+ !has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
+ T const&, T&&>::type legacy_move(T& x);`
+
+ :raw-html:`<span class="ins">10 <em>Returns:</em> <code>t</code></span>`
+
+20.6.2 Header ``<type_traits>`` synopsis [meta.type.synop]
+==========================================================
.. parsed-literal::
Modified: sandbox/committee/rvalue_ref/N2983.html
==============================================================================
--- sandbox/committee/rvalue_ref/N2983.html (original)
+++ sandbox/committee/rvalue_ref/N2983.html 2009-10-19 12:22:15 EDT (Mon, 19 Oct 2009)
@@ -332,14 +332,21 @@
<li><a class="reference internal" href="#an-optimization-hint" id="id10">An Optimization Hint</a></li>
<li><a class="reference internal" href="#interactions-with-other-proposals" id="id11">Interactions with Other Proposals</a></li>
<li><a class="reference internal" href="#existing-practice" id="id12">Existing Practice</a></li>
-<li><a class="reference internal" href="#proposed-changes-to-standard-wording" id="id13">Proposed Changes to Standard Wording</a><ul>
-<li><a class="reference internal" href="#exception-specifications-except-spec" id="id14">15.4 Exception specifications [except.spec]</a></li>
-<li><a class="reference internal" href="#a-13-exception-handling-gram-except" id="id15">A.13 Exception handling [gram.except]</a></li>
-<li><a class="reference internal" href="#header-type-traits-synopsis-meta-type-synop" id="id16">20.6.2 Header <type_traits> synopsis [meta.type.synop]</a></li>
-<li><a class="reference internal" href="#type-properties-meta-unary-prop" id="id17">20.6.4.3 Type properties [meta.unary.prop]</a></li>
-<li><a class="reference internal" href="#deque-modifiers-deque-modifiers" id="id18">23.3.2.3 deque modifiers [deque.modifiers]</a></li>
-<li><a class="reference internal" href="#vector-capacity-vector-capacity" id="id19">23.3.6.2 vector capacity [vector.capacity]</a></li>
-<li><a class="reference internal" href="#vector-modifiers-vector-modifiers" id="id20">23.3.6.4 vector modifiers [vector.modifiers]</a></li>
+<li><a class="reference internal" href="#low-hanging-fruit" id="id13">Low-Hanging Fruit</a><ul>
+<li><a class="reference internal" href="#implicit-throw-false-for-destructors" id="id14">Implicit <tt class="docutils literal"><span class="pre">throw(false)</span></tt> for Destructors</a></li>
+<li><a class="reference internal" href="#operator-may-throw-expression" id="id15">operator <tt class="docutils literal"><span class="pre">may_throw(</span></tt><em>expression</em><tt class="docutils literal"><span class="pre">)</span></tt></a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#proposed-changes-to-standard-wording" id="id16">Proposed Changes to Standard Wording</a><ul>
+<li><a class="reference internal" href="#exception-specifications-except-spec" id="id17">15.4 Exception specifications [except.spec]</a></li>
+<li><a class="reference internal" href="#a-13-exception-handling-gram-except" id="id18">A.13 Exception handling [gram.except]</a></li>
+<li><a class="reference internal" href="#utility-components-utility" id="id19">20.3 Utility components [utility]</a></li>
+<li><a class="reference internal" href="#forward-move-helpers-forward" id="id20">20.3.2 forward/move helpers [forward]</a></li>
+<li><a class="reference internal" href="#header-type-traits-synopsis-meta-type-synop" id="id21">20.6.2 Header <tt class="docutils literal"><span class="pre"><type_traits></span></tt> synopsis [meta.type.synop]</a></li>
+<li><a class="reference internal" href="#type-properties-meta-unary-prop" id="id22">20.6.4.3 Type properties [meta.unary.prop]</a></li>
+<li><a class="reference internal" href="#deque-modifiers-deque-modifiers" id="id23">23.3.2.3 deque modifiers [deque.modifiers]</a></li>
+<li><a class="reference internal" href="#vector-capacity-vector-capacity" id="id24">23.3.6.2 vector capacity [vector.capacity]</a></li>
+<li><a class="reference internal" href="#vector-modifiers-vector-modifiers" id="id25">23.3.6.4 vector modifiers [vector.modifiers]</a></li>
</ul>
</li>
</ul>
@@ -549,10 +556,32 @@
in the standard. Standardizing <tt class="docutils literal"><span class="pre">throw(false)</span></tt> gives everyone access
to this optimization tool.</p>
</div>
+<div class="section" id="low-hanging-fruit">
+<h1><a class="toc-backref" href="#id13">Low-Hanging Fruit</a></h1>
+<p>There are a couple of additional features we think the committee
+should consider if this proposal is accepted.</p>
+<div class="section" id="implicit-throw-false-for-destructors">
+<h2><a class="toc-backref" href="#id14">Implicit <tt class="docutils literal"><span class="pre">throw(false)</span></tt> for Destructors</a></h2>
+<p>So few destructors can throw exceptions that the default
+exception-specification for destructors could be changed from nothing
+(i.e. <tt class="docutils literal"><span class="pre">throw(true)</span></tt>) to <tt class="docutils literal"><span class="pre">throw(false)</span></tt> with only a tiny amount of code
+breakage. Such code is already very dangerous, and where used
+properly, ought to be a well-known âcaution areaâ that is reasonably
+easily migrated.</p>
+</div>
+<div class="section" id="operator-may-throw-expression">
+<h2><a class="toc-backref" href="#id15">operator <tt class="docutils literal"><span class="pre">may_throw(</span></tt><em>expression</em><tt class="docutils literal"><span class="pre">)</span></tt></a></h2>
+<p>It seems that <tt class="docutils literal"><span class="pre">has_nothrow_</span></tt><em>xxx</em> traits are proliferating (and
+not just in this proposal). Once we have <tt class="docutils literal"><span class="pre">throw(</span></tt><em>bool-constant-expr</em><tt class="docutils literal"><span class="pre">)</span></tt> available to make the information
+available, it makes sense to generalize the traits into an operator
+similar to <tt class="docutils literal"><span class="pre">sizeof</span></tt> and <tt class="docutils literal"><span class="pre">typeof</span></tt> that can give us answers about
+<em>any</em> expression.</p>
+</div>
+</div>
<div class="section" id="proposed-changes-to-standard-wording">
-<h1><a class="toc-backref" href="#id13">Proposed Changes to Standard Wording</a></h1>
+<h1><a class="toc-backref" href="#id16">Proposed Changes to Standard Wording</a></h1>
<div class="section" id="exception-specifications-except-spec">
-<h2><a class="toc-backref" href="#id14">15.4 Exception specifications [except.spec]</a></h2>
+<h2><a class="toc-backref" href="#id17">15.4 Exception specifications [except.spec]</a></h2>
<p>Change paragraph 1 as follows:</p>
<blockquote>
<p>1 A function declaration lists exceptions that its function might directly
@@ -584,15 +613,40 @@
</blockquote>
</div>
<div class="section" id="a-13-exception-handling-gram-except">
-<h2><a class="toc-backref" href="#id15">A.13 Exception handling [gram.except]</a></h2>
+<h2><a class="toc-backref" href="#id18">A.13 Exception handling [gram.except]</a></h2>
<pre class="literal-block">
exception-specification
throw ( type-id-listopt )
<span class="ins">throw(constant-expression)</span>
</pre>
</div>
+<div class="section" id="utility-components-utility">
+<h2><a class="toc-backref" href="#id19">20.3 Utility components [utility]</a></h2>
+<p>Change Header <tt class="docutils literal"><span class="pre"><utility></span></tt> synopsis as follows:</p>
+<pre class="literal-block">
+// 20.3.2, forward/move:
+template <class T> struct identity;
+template <class T> T&& forward(typename identity<T>::type&&);
+template <class T> typename remove_reference<T>::type&& move(T&&);
+<span class="ins">template <class T> typename conditional<
+ !has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
+ T const&, T&&>::type legacy_move(T& x);</span>
+</pre>
+</div>
+<div class="section" id="forward-move-helpers-forward">
+<h2><a class="toc-backref" href="#id20">20.3.2 forward/move helpers [forward]</a></h2>
+<p>Append the following:</p>
+<blockquote>
+<pre class="literal-block">
+<span class="ins">template <class T> typename conditional<
+ !has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
+ T const&, T&&>::type legacy_move(T& x);</span>
+</pre>
+<p><span class="raw-html"><span class="ins">10 <em>Returns:</em> <code>t</code></span></span></p>
+</blockquote>
+</div>
<div class="section" id="header-type-traits-synopsis-meta-type-synop">
-<h2><a class="toc-backref" href="#id16">20.6.2 Header <type_traits> synopsis [meta.type.synop]</a></h2>
+<h2><a class="toc-backref" href="#id21">20.6.2 Header <tt class="docutils literal"><span class="pre"><type_traits></span></tt> synopsis [meta.type.synop]</a></h2>
<pre class="literal-block">
template <class T> struct has_nothrow_assign;
<span class="ins">template <class T> struct has_move_constructor;
@@ -609,7 +663,7 @@
</pre>
</div>
<div class="section" id="type-properties-meta-unary-prop">
-<h2><a class="toc-backref" href="#id17">20.6.4.3 Type properties [meta.unary.prop]</a></h2>
+<h2><a class="toc-backref" href="#id22">20.6.4.3 Type properties [meta.unary.prop]</a></h2>
<p>Add entries to table 43:</p>
<table border="1" class="docutils">
<colgroup>
@@ -683,7 +737,7 @@
</table>
</div>
<div class="section" id="deque-modifiers-deque-modifiers">
-<h2><a class="toc-backref" href="#id18">23.3.2.3 deque modifiers [deque.modifiers]</a></h2>
+<h2><a class="toc-backref" href="#id23">23.3.2.3 deque modifiers [deque.modifiers]</a></h2>
<p>Context:</p>
<pre class="literal-block">
iterator insert(const_iterator position, const T& x);
@@ -722,7 +776,7 @@
or assignment operator of <tt class="docutils literal"><span class="pre">T</span></tt>.</blockquote>
</div>
<div class="section" id="vector-capacity-vector-capacity">
-<h2><a class="toc-backref" href="#id19">23.3.6.2 vector capacity [vector.capacity]</a></h2>
+<h2><a class="toc-backref" href="#id24">23.3.6.2 vector capacity [vector.capacity]</a></h2>
<p>Context:</p>
<pre class="literal-block">
void reserve(size_type n);
@@ -755,7 +809,7 @@
<code>T</code></span></span> there are no effects.</blockquote>
</div>
<div class="section" id="vector-modifiers-vector-modifiers">
-<h2><a class="toc-backref" href="#id20">23.3.6.4 vector modifiers [vector.modifiers]</a></h2>
+<h2><a class="toc-backref" href="#id25">23.3.6.4 vector modifiers [vector.modifiers]</a></h2>
<p>Change the section as follows:</p>
<blockquote>
<pre class="literal-block">
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk