|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53239 - in branches/release/libs/exception/doc: . source
From: emil_at_[hidden]
Date: 2009-05-25 02:13:42
Author: emildotchevski
Date: 2009-05-25 02:13:42 EDT (Mon, 25 May 2009)
New Revision: 53239
URL: http://svn.boost.org/trac/boost/changeset/53239
Log:
documentation update
Text files modified:
branches/release/libs/exception/doc/frequently_asked_questions.html | 7 +++++++
branches/release/libs/exception/doc/source/boost-exception.reno | 31 +++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
Modified: branches/release/libs/exception/doc/frequently_asked_questions.html
==============================================================================
--- branches/release/libs/exception/doc/frequently_asked_questions.html (original)
+++ branches/release/libs/exception/doc/frequently_asked_questions.html 2009-05-25 02:13:42 EDT (Mon, 25 May 2009)
@@ -79,6 +79,13 @@
throw e;</pre>
<p>and looks better than something like:</p>
<pre>throw error().add(foo_info(foo)).add(bar_info(bar));</pre>
+<h3>Why is operator<< allowed to throw?</h3>
+<p>This question is referring to the following issue. Consider this throw statement example:</p>
+<pre>throw file_open_error() <span class="RenoLink"><<</span> file_name(fn);</pre>
+<p>The intention here is to throw a file_open_error, however if <span class="RenoLink">operator<<</span> fails to copy the std::string contained in the file_name <span class="RenoLink">error_info</span> wrapper, a std::bad_alloc could propagate instead. This behavior seems undesirable to some programmers.</p>
+<p>Bjarne Stroustrup, The C++ Programming Language, 3rd Edition, page 371:</p>
+<blockquote><p><i>"Throwing an exception requires an object to throw. A C++ implementation is required to have enough spare memory to be able to throw bad_alloc in case of memory exhaustion. However, it is possible that throwing some other exception will cause memory exhaustion."</i></p></blockquote>
+<p>So, an attempt to throw any exception may already result in propagating std::bad_alloc instead.</p>
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>
<div class="RenoPageList"><a href="boost-exception.html">Boost Exception<br/>
Modified: branches/release/libs/exception/doc/source/boost-exception.reno
==============================================================================
--- branches/release/libs/exception/doc/source/boost-exception.reno (original)
+++ branches/release/libs/exception/doc/source/boost-exception.reno 2009-05-25 02:13:42 EDT (Mon, 25 May 2009)
@@ -5561,7 +5561,7 @@
</shared_ptr>
</weak_ptr>
<container>
- <size>65</size>
+ <size>71</size>
<variant>2</variant>
<string>(:auto !!:) !!!Why doesn't boost::exception derive from std::exception? Despite that (:link </string>
<variant>1</variant>
@@ -5851,7 +5851,34 @@
</shared_ptr>
</weak_ptr>
<variant>2</variant>
- <string>|<<:) bar_info(bar);@] which saves typing compared to this possible alternative: [@error e; e.add(foo_info(foo)); e.add(bar_info(bar)); throw e;@] and looks better than something like: [@throw error().add(foo_info(foo)).add(bar_info(bar));@] </string>
+ <string>|<<:) bar_info(bar);@] which saves typing compared to this possible alternative: [@error e; e.add(foo_info(foo)); e.add(bar_info(bar)); throw e;@] and looks better than something like: [@throw error().add(foo_info(foo)).add(bar_info(bar));@] !!!Why is operator<< allowed to throw? This question is referring to the following issue. Consider this throw statement example: [@throw file_open_error() (:link </string>
+ <variant>1</variant>
+ <weak_ptr>
+ <expired>0</expired>
+ <shared_ptr>
+ <id>-52</id>
+ </shared_ptr>
+ </weak_ptr>
+ <variant>2</variant>
+ <string>|<<:) file_name(fn);@] The intention here is to throw a file_open_error, however if (:link </string>
+ <variant>1</variant>
+ <weak_ptr>
+ <expired>0</expired>
+ <shared_ptr>
+ <id>-52</id>
+ </shared_ptr>
+ </weak_ptr>
+ <variant>2</variant>
+ <string> mod="/":) fails to copy the std::string contained in the file_name </string>
+ <variant>1</variant>
+ <weak_ptr>
+ <expired>0</expired>
+ <shared_ptr>
+ <id>-18</id>
+ </shared_ptr>
+ </weak_ptr>
+ <variant>2</variant>
+ <string> wrapper, a std::bad_alloc could propagate instead. This behavior seems undesirable to some programmers. Bjarne Stroustrup, The C++ Programming Language, 3rd Edition, page 371: ->''"Throwing an exception requires an object to throw. A C++ implementation is required to have enough spare memory to be able to throw bad_alloc in case of memory exhaustion. However, it is possible that throwing some other exception will cause memory exhaustion."'' So, an attempt to throw any exception may already result in propagating std::bad_alloc instead. </string>
</container>
</pair>
<pair>
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