CopyConstructible.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
  6. <title>Copy Constructible</title>
  7. </head>
  8. <body bgcolor="#FFFFFF" link="#0000EE" text="#000000" vlink="#551A8B" alink=
  9. "#FF0000">
  10. <img src="../../boost.png" alt="C++ Boost" width="277" height=
  11. "86"><br clear="none">
  12. <h1>Copy Constructible</h1>
  13. <h3>Description</h3>
  14. <p>A type is Copy Constructible if it is possible to copy objects of that
  15. type.</p>
  16. <h3>Notation</h3>
  17. <table summary="">
  18. <tr>
  19. <td valign="top"><tt>T</tt></td>
  20. <td valign="top">is type that is a model of Copy Constructible</td>
  21. </tr>
  22. <tr>
  23. <td valign="top"><tt>t</tt></td>
  24. <td valign="top">is an object of type <tt>T</tt></td>
  25. </tr>
  26. <tr>
  27. <td valign="top"><tt>u</tt></td>
  28. <td valign="top">is an object of type <tt>const T</tt></td>
  29. </tr>
  30. </table>
  31. <h3>Definitions</h3>
  32. <h3>Valid expressions</h3>
  33. <table border summary="">
  34. <tr>
  35. <th>Name</th>
  36. <th>Expression</th>
  37. <th>Return type</th>
  38. <th>Semantics</th>
  39. </tr>
  40. <tr>
  41. <td valign="top">Copy constructor</td>
  42. <td valign="top"><tt>T(t)</tt></td>
  43. <td valign="top"><tt>T</tt></td>
  44. <td valign="top"><tt>t</tt> is equivalent to <tt>T(t)</tt></td>
  45. </tr>
  46. <tr>
  47. <td valign="top">Copy constructor</td>
  48. <td valign="top">
  49. <pre>
  50. T(u)
  51. </pre>
  52. </td>
  53. <td valign="top"><tt>T</tt></td>
  54. <td valign="top"><tt>u</tt> is equivalent to <tt>T(u)</tt></td>
  55. </tr>
  56. <tr>
  57. <td valign="top">Destructor</td>
  58. <td valign="top">
  59. <pre>
  60. t.~T()
  61. </pre>
  62. </td>
  63. <td valign="top"><tt>T</tt></td>
  64. <td valign="top">&nbsp;</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">Address Operator</td>
  68. <td valign="top">
  69. <pre>
  70. &amp;t
  71. </pre>
  72. </td>
  73. <td valign="top"><tt>T*</tt></td>
  74. <td valign="top">denotes the address of <tt>t</tt></td>
  75. </tr>
  76. <tr>
  77. <td valign="top">Address Operator</td>
  78. <td valign="top">
  79. <pre>
  80. &amp;u
  81. </pre>
  82. </td>
  83. <td valign="top"><tt>T*</tt></td>
  84. <td valign="top">denotes the address of <tt>u</tt></td>
  85. </tr>
  86. </table>
  87. <h3>Models</h3>
  88. <ul>
  89. <li><tt>int</tt></li>
  90. <li><tt>std::pair</tt></li>
  91. </ul>
  92. <h3>Concept Checking Class</h3>
  93. <pre>
  94. template &lt;class T&gt;
  95. struct CopyConstructibleConcept
  96. {
  97. void constraints() {
  98. T a(b); // require copy constructor
  99. T* ptr = &amp;a; // require address of operator
  100. const_constraints(a);
  101. ignore_unused_variable_warning(ptr);
  102. }
  103. void const_constraints(const T&amp; a) {
  104. T c(a); // require const copy constructor
  105. const T* ptr = &amp;a; // require const address of operator
  106. ignore_unused_variable_warning(c);
  107. ignore_unused_variable_warning(ptr);
  108. }
  109. T b;
  110. };
  111. </pre>
  112. <h3>See also</h3>
  113. <p><a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
  114. Constructible</a> and <a href="./Assignable.html">Assignable</a><br></p>
  115. <hr>
  116. <p><a href="http://validator.w3.org/check?uri=referer"><img border="0" src=
  117. "../../doc/images/valid-html401.png" alt="Valid HTML 4.01 Transitional"
  118. height="31" width="88"></a></p>
  119. <p>Revised
  120. <!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05
  121. December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
  122. <table summary="">
  123. <tr valign="top">
  124. <td nowrap><i>Copyright &copy; 2000</i></td>
  125. <td><i><a href="http://www.lsc.nd.edu/~jsiek">Jeremy Siek</a>, Univ.of
  126. Notre Dame (<a href=
  127. "mailto:jsiek@lsc.nd.edu">jsiek@lsc.nd.edu</a>)</i></td>
  128. </tr>
  129. </table>
  130. <p><i>Distributed under the Boost Software License, Version 1.0. (See
  131. accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or
  132. copy at <a href=
  133. "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
  134. </body>
  135. </html>