diff options
Diffstat (limited to 'libstdc++-v3/doc/html/19_diagnostics/howto.html')
-rw-r--r-- | libstdc++-v3/doc/html/19_diagnostics/howto.html | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/libstdc++-v3/doc/html/19_diagnostics/howto.html b/libstdc++-v3/doc/html/19_diagnostics/howto.html new file mode 100644 index 00000000000..90a60b3bca5 --- /dev/null +++ b/libstdc++-v3/doc/html/19_diagnostics/howto.html @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!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=iso-8859-1" /> + <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)" /> + <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL" /> + <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 19." /> + <meta name="GENERATOR" content="vi and eight fingers" /> + <title>libstdc++ HOWTO: Chapter 19: Diagnostics</title> +<link rel="StyleSheet" href="../lib3styles.css" type="text/css" /> +<link rel="Start" href="../documentation.html" type="text/html" + title="GNU C++ Standard Library" /> +<link rel="Prev" href="../18_support/howto.html" type="text/html" + title="Library Support" /> +<link rel="Next" href="../20_util/howto.html" type="text/html" + title="General Utilities" /> +<link rel="Copyright" href="../17_intro/license.html" type="text/html" /> +<link rel="Help" href="../faq/index.html" type="text/html" title="F.A.Q." /> +</head> +<body> + +<h1 class="centered"><a name="top">Chapter 19: Diagnostics</a></h1> + +<p>Chapter 19 deals with program diagnostics, such as exceptions + and assertions. You know, all the things we wish weren't even + necessary at all. +</p> + + +<!-- ####################################################### --> +<hr /> +<h1>Contents</h1> +<ul> + <li><a href="#1">Adding data to exceptions</a></li> + <li><a href="#3">Concept checkers -- <strong>new and improved!</strong></a></li> +</ul> + +<hr /> + +<!-- ####################################################### --> + +<h2><a name="1">Adding data to exceptions</a></h2> + <p>The standard exception classes carry with them a single string as + data (usually describing what went wrong or where the 'throw' took + place). It's good to remember that you can add your own data to + these exceptions when extending the hierarchy: + </p> + <pre> + struct My_Exception : public std::runtime_error + { + public: + My_Exception (const string& whatarg) + : std::runtime_error(whatarg), e(errno), id(GetDataBaseID()) { } + int errno_at_time_of_throw() const { return e; } + DBID id_of_thing_that_threw() const { return id; } + protected: + int e; + DBID id; // some user-defined type + }; + </pre> + <p>Return <a href="#top">to top of page</a> or + <a href="../faq/index.html">to the FAQ</a>. + </p> + +<hr /> +<h2><a name="3">Concept checkers -- <strong>new and improved!</strong></a></h2> + <p>Better taste! Less fat! Literally!</p> + <p>In 1999, SGI added <em>concept checkers</em> to their implementation + of the STL: code which checked the template parameters of + instantiated pieces of the STL, in order to insure that the parameters + being used met the requirements of the standard. For example, + the Standard requires that types passed as template parameters to + <code>vector</code> be "Assignable" (which means what you think + it means). The checking was done during compilation, and none of + the code was executed at runtime. + </p> + <p>Unfortunately, the size of the compiler files grew significantly + as a result. The checking code itself was cumbersome. And bugs + were found in it on more than one occasion. + </p> + <p>The primary author of the checking code, Jeremy Siek, had already + started work on a replacement implementation. The new code has been + formally reviewed and accepted into + <a href="http://www.boost.org/libs/concept_check/concept_check.htm">the + Boost libraries</a>, and we are pleased to incorporate it into the + GNU C++ library. + </p> + <p>The new version imposes a much smaller space overhead on the generated + object file. The checks are also cleaner and easier to read and + understand. + </p> + <p>They are off by default for all versions of GCC from 3.0 to 3.4 (the + latest release at the time of writing). + They can be enabled at configure time with + <a href="../configopts.html"><code>--enable-concept-checks</code></a>. + You can enable them on a per-translation-unit basis with + <code>#define _GLIBCXX_CONCEPT_CHECKS</code> for GCC 3.4 and higher + (or with <code>#define _GLIBCPP_CONCEPT_CHECKS</code> for versions + 3.1, 3.2 and 3.3). + </p> + + <p>Please note that the upcoming C++ standard has first-class + support for template parameter constraints based on concepts in the core + language. This will obviate the need for the library-simulated concept + checking described above. + </p> + + <p>Return <a href="#top">to top of page</a> or + <a href="../faq/index.html">to the FAQ</a>. + </p> + +<!-- ####################################################### --> + +<hr /> +<p class="fineprint"><em> +See <a href="../17_intro/license.html">license.html</a> for copying conditions. +Comments and suggestions are welcome, and may be sent to +<a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>. +</em></p> + + +</body> +</html> |