123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Language" content="en-us">
- <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
- <title>Copy Constructible</title>
- </head>
- <body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
- "#FF0000">
- <img src="../../boost.png" alt="C++ Boost" width="277" height=
- "86"><br clear="none">
- <h1>Copy Constructible</h1>
- <h3>Description</h3>
- <p>A type is Copy Constructible if it is possible to copy objects of that
- type.</p>
- <h3>Notation</h3>
- <table summary="">
- <tr>
- <td valign="top"><tt>T</tt></td>
- <td valign="top">is type that is a model of Copy Constructible</td>
- </tr>
- <tr>
- <td valign="top"><tt>t</tt></td>
- <td valign="top">is an object of type <tt>T</tt></td>
- </tr>
- <tr>
- <td valign="top"><tt>u</tt></td>
- <td valign="top">is an object of type <tt>const T</tt></td>
- </tr>
- </table>
- <h3>Definitions</h3>
- <h3>Valid expressions</h3>
- <table border summary="">
- <tr>
- <th>Name</th>
- <th>Expression</th>
- <th>Return type</th>
- <th>Semantics</th>
- </tr>
- <tr>
- <td valign="top">Copy constructor</td>
- <td valign="top"><tt>T(t)</tt></td>
- <td valign="top"><tt>T</tt></td>
- <td valign="top"><tt>t</tt> is equivalent to <tt>T(t)</tt></td>
- </tr>
- <tr>
- <td valign="top">Copy constructor</td>
- <td valign="top">
- <pre>
- T(u)
- </pre>
- </td>
- <td valign="top"><tt>T</tt></td>
- <td valign="top"><tt>u</tt> is equivalent to <tt>T(u)</tt></td>
- </tr>
- <tr>
- <td valign="top">Destructor</td>
- <td valign="top">
- <pre>
- t.~T()
- </pre>
- </td>
- <td valign="top"><tt>T</tt></td>
- <td valign="top"> </td>
- </tr>
- <tr>
- <td valign="top">Address Operator</td>
- <td valign="top">
- <pre>
- &t
- </pre>
- </td>
- <td valign="top"><tt>T*</tt></td>
- <td valign="top">denotes the address of <tt>t</tt></td>
- </tr>
- <tr>
- <td valign="top">Address Operator</td>
- <td valign="top">
- <pre>
- &u
- </pre>
- </td>
- <td valign="top"><tt>T*</tt></td>
- <td valign="top">denotes the address of <tt>u</tt></td>
- </tr>
- </table>
- <h3>Models</h3>
- <ul>
- <li><tt>int</tt></li>
- <li><tt>std::pair</tt></li>
- </ul>
- <h3>Concept Checking Class</h3>
- <pre>
- template <class T>
- struct CopyConstructibleConcept
- {
- void constraints() {
- T a(b); // require copy constructor
- T* ptr = &a; // require address of operator
- const_constraints(a);
- ignore_unused_variable_warning(ptr);
- }
- void const_constraints(const T& a) {
- T c(a); // require const copy constructor
- const T* ptr = &a; // require const address of operator
- ignore_unused_variable_warning(c);
- ignore_unused_variable_warning(ptr);
- }
- T b;
- };
- </pre>
- <h3>See also</h3>
- <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
- Constructible</a> and <a href="./Assignable.html">Assignable</a><br></p>
- <hr>
- <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
- "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
- height="31" width="88"></a></p>
- <p>Revised
- <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
- December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
- <table summary="">
- <tr valign="top">
- <td nowrap><i>Copyright © 2000</i></td>
- <td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
- Notre Dame (<a href=
- "mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
- </tr>
- </table>
- <p><i>Distributed under 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">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
- </body>
- </html>
|