You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### <a name="TBD"></a>Use of `=`, `{}`, and `()` as initializers
15025
15023
@@ -15031,7 +15029,7 @@ If your design wants virtual dispatch into a derived class from a base class con
15031
15029
15032
15030
* *Pass the buck:* Just document that user code must call the post-initialization function right after constructing an object.
15033
15031
* *Post-initialize lazily:* Do it during the first call of a member function. A Boolean flag in the base class tells whether or not post-construction has taken place yet.
15034
-
* *Use virtual base class semantics:* Language rules dictate that the constructor most-derived class decides which base constructor will be invoked; you can use that to your advantage. (See [[Taligent94]](#Taligent94).)
15032
+
* *Use virtual base class semantics:* Language rules dictate that the constructor most-derived class decides which base constructor will be invoked; you can use that to your advantage. (See [\[Taligent94\]](#Taligent94).)
15035
15033
* *Use a factory function:* This way, you can easily force a mandatory invocation of a post-constructor function.
15036
15034
15037
15035
Here is an example of the last option:
@@ -15086,7 +15084,7 @@ If the requirements above are met, the design guarantees that `PostInitialize` h
15086
15084
15087
15085
In summary, no post-construction technique is perfect. The worst techniques dodge the whole issue by simply asking the caller to invoke the post-constructor manually. Even the best require a different syntax for constructing objects (easy to check at compile time) and/or cooperation from derived class authors (impossible to check at compile time).
### <a name="Sd-dtor"></a>Discussion: Make base class destructors public and virtual, or protected and nonvirtual
15092
15090
@@ -15157,7 +15155,7 @@ In this rare case, you could make the destructor public and nonvirtual but clear
15157
15155
15158
15156
In general, however, avoid concrete base classes (see Item 35). For example, `unary_function` is a bundle-of-typedefs that was never intended to be instantiated standalone. It really makes no sense to give it a public destructor; a better design would be to follow this Item's advice and give it a protected nonvirtual destructor.
### <a name="Sd-noexcept"></a>Discussion: Usage of noexcept
15163
15161
@@ -15231,9 +15229,9 @@ These are key functions that must not fail because they are necessary for the tw
15231
15229
15232
15230
Consider the following advice and requirements found in the C++ Standard:
15233
15231
15234
-
> If a destructor called during stack unwinding exits with an exception, terminate is called (15.5.1). So destructors should generally catch exceptions and not let them propagate out of the destructor. --[[C++03]](#C++03) §15.2(3)
15232
+
> If a destructor called during stack unwinding exits with an exception, terminate is called (15.5.1). So destructors should generally catch exceptions and not let them propagate out of the destructor. --[\[C++03\]](#C++03) §15.2(3)
15235
15233
>
15236
-
> No destructor operation defined in the C++ Standard Library (including the destructor of any type that is used to instantiate a standard library template) will throw an exception. --[[C++03]](#C++03) §17.4.4.8(3)
15234
+
> No destructor operation defined in the C++ Standard Library (including the destructor of any type that is used to instantiate a standard library template) will throw an exception. --[\[C++03\]](#C++03) §17.4.4.8(3)
15237
15235
15238
15236
Deallocation functions, including specifically overloaded `operator delete` and `operator delete[]`, fall into the same category, because they too are used during cleanup in general, and during exception handling in particular, to back out of partial work that needs to be undone.
15239
15237
Besides destructors and deallocation functions, common error-safety techniques rely also on `swap` operations never failing--in this case, not because they are used to implement a guaranteed rollback, but because they are used to implement a guaranteed commit. For example, here is an idiomatic implementation of `operator=` for a type `T` that performs copy construction followed by a call to a no-fail `swap`:
@@ -15249,7 +15247,7 @@ Fortunately, when releasing a resource, the scope for failure is definitely smal
15249
15247
15250
15248
When using exceptions as your error handling mechanism, always document this behavior by declaring these functions `noexcept`. (See Item 75.)
## <a name="Sd-consistent"></a>Define Copy, move, and destroy consistently
15255
15253
@@ -15335,7 +15333,7 @@ Prefer compiler-generated (including `=default`) special members; only these can
15335
15333
In rare cases, classes that have members of strange types (such as reference members) are an exception because they have peculiar copy semantics.
15336
15334
In a class holding a reference, you likely need to write the copy constructor and the assignment operator, but the default destructor already does the right thing. (Note that using a reference member is almost always wrong.)
@@ -15739,49 +15737,49 @@ Alternatively, we will decide that no change is needed and delete the entry.
15739
15737
# Bibliography
15740
15738
15741
15739
* <a name="Alexandrescu01"></a>
15742
-
[Alexandrescu01]: A. Alexandrescu. Modern C++ Design (Addison-Wesley, 2001).
15740
+
\[Alexandrescu01]: A. Alexandrescu. Modern C++ Design (Addison-Wesley, 2001).
15743
15741
* <a name="Cplusplus03"></a>
15744
-
[C++03]: ISO/IEC 14882:2003(E), Programming Languages — C++ (updated ISO and ANSI C++ Standard including the contents of (C++98) plus errata corrections).
15742
+
\[C++03]: ISO/IEC 14882:2003(E), Programming Languages — C++ (updated ISO and ANSI C++ Standard including the contents of (C++98) plus errata corrections).
15745
15743
* <a name="CplusplusCS"></a>
15746
-
[C++CS]:
15744
+
\[C++CS]:
15747
15745
* <a name="Cargill92"></a>
15748
-
[Cargill92]: T. Cargill. C++ Programming Style (Addison-Wesley, 1992).
15746
+
\[Cargill92]: T. Cargill. C++ Programming Style (Addison-Wesley, 1992).
15749
15747
* <a name="Cline99"></a>
15750
-
[Cline99]: M. Cline, G. Lomow, and M. Girou. C++ FAQs (2ndEdition) (Addison-Wesley, 1999).
15748
+
\[Cline99]: M. Cline, G. Lomow, and M. Girou. C++ FAQs (2ndEdition) (Addison-Wesley, 1999).
15751
15749
* <a name="Dewhurst03"></a>
15752
-
[Dewhurst03]: S. Dewhurst. C++ Gotchas (Addison-Wesley, 2003).
15750
+
\[Dewhurst03]: S. Dewhurst. C++ Gotchas (Addison-Wesley, 2003).
15753
15751
* <a name="Henricson97"></a>
15754
-
[Henricson97]: M. Henricson and E. Nyquist. Industrial Strength C++ (Prentice Hall, 1997).
15752
+
\[Henricson97]: M. Henricson and E. Nyquist. Industrial Strength C++ (Prentice Hall, 1997).
15755
15753
* <a name="Koenig97"></a>
15756
-
[Koenig97]: A. Koenig and B. Moo. Ruminations on C++ (Addison-Wesley, 1997).
15754
+
\[Koenig97]: A. Koenig and B. Moo. Ruminations on C++ (Addison-Wesley, 1997).
15757
15755
* <a name="Lakos96"></a>
15758
-
[Lakos96]: J. Lakos. Large-Scale C++ Software Design (Addison-Wesley, 1996).
15756
+
\[Lakos96]: J. Lakos. Large-Scale C++ Software Design (Addison-Wesley, 1996).
15759
15757
* <a name="Meyers96"></a>
15760
-
[Meyers96]: S. Meyers. More Effective C++ (Addison-Wesley, 1996).
15758
+
\[Meyers96]: S. Meyers. More Effective C++ (Addison-Wesley, 1996).
15761
15759
* <a name="Meyers97"></a>
15762
-
[Meyers97]: S. Meyers. Effective C++ (2nd Edition) (Addison-Wesley, 1997).
15760
+
\[Meyers97]: S. Meyers. Effective C++ (2nd Edition) (Addison-Wesley, 1997).
15763
15761
* <a name="Meyers15"></a>
15764
-
[Meyers15]: S. Meyers. Effective Modern C++ (O'Reilly, 2015).
15762
+
\[Meyers15]: S. Meyers. Effective Modern C++ (O'Reilly, 2015).
15765
15763
* <a name="Murray93"></a>
15766
-
[Murray93]: R. Murray. C++ Strategies and Tactics (Addison-Wesley, 1993).
15764
+
\[Murray93]: R. Murray. C++ Strategies and Tactics (Addison-Wesley, 1993).
15767
15765
* <a name="Stroustrup00"></a>
15768
-
[Stroustrup00]: B. Stroustrup. The C++ Programming Language (Special 3rdEdition) (Addison-Wesley, 2000).
15766
+
\[Stroustrup00]: B. Stroustrup. The C++ Programming Language (Special 3rdEdition) (Addison-Wesley, 2000).
15769
15767
* <a name="Stroustrup05"></a>
15770
-
[Stroustrup05]: B. Stroustrup. [A rationale for semantically enhanced library languages](http://www.stroustrup.com/SELLrationale.pdf).
15768
+
\[Stroustrup05]: B. Stroustrup. [A rationale for semantically enhanced library languages](http://www.stroustrup.com/SELLrationale.pdf).
15771
15769
* <a name="Stroustrup13"></a>
15772
-
[Stroustrup13]: B. Stroustrup. [The C++ Programming Language (4th Edition)](http://www.stroustrup.com/4th.html). Addison Wesley 2013.
15770
+
\[Stroustrup13]: B. Stroustrup. [The C++ Programming Language (4th Edition)](http://www.stroustrup.com/4th.html). Addison Wesley 2013.
15773
15771
* <a name="Stroustrup14"></a>
15774
-
[Stroustrup14]: B. Stroustrup. [A Tour of C++](http://www.stroustrup.com/Tour.html).
15772
+
\[Stroustrup14]: B. Stroustrup. [A Tour of C++](http://www.stroustrup.com/Tour.html).
15775
15773
Addison Wesley 2014.
15776
15774
* <a name="SuttHysl04b"></a>
15777
-
[SuttHysl04b]: H. Sutter and J. Hyslop. "Collecting Shared Objects" (C/C++ Users Journal, 22(8), August 2004).
15775
+
\[SuttHysl04b]: H. Sutter and J. Hyslop. "Collecting Shared Objects" (C/C++ Users Journal, 22(8), August 2004).
15778
15776
* <a name="SuttAlex05"></a>
15779
-
[SuttAlex05]: H. Sutter and A. Alexandrescu. C++ Coding Standards. Addison-Wesley 2005.
15777
+
\[SuttAlex05]: H. Sutter and A. Alexandrescu. C++ Coding Standards. Addison-Wesley 2005.
15780
15778
* <a name="Sutter00"></a>
15781
-
[Sutter00]: H. Sutter. Exceptional C++ (Addison-Wesley, 2000).
15779
+
\[Sutter00]: H. Sutter. Exceptional C++ (Addison-Wesley, 2000).
15782
15780
* <a name="Sutter02"></a>
15783
-
[Sutter02]: H. Sutter. More Exceptional C++ (Addison-Wesley, 2002).
15781
+
\[Sutter02]: H. Sutter. More Exceptional C++ (Addison-Wesley, 2002).
15784
15782
* <a name="Sutter04"></a>
15785
-
[Sutter04]: H. Sutter. Exceptional C++ Style (Addison-Wesley, 2004).
15783
+
\[Sutter04]: H. Sutter. Exceptional C++ Style (Addison-Wesley, 2004).
15786
15784
* <a name="Taligent94"></a>
15787
-
[Taligent94]: Taligent's Guide to Designing Programs (Addison-Wesley, 1994).
15785
+
\[Taligent94]: Taligent's Guide to Designing Programs (Addison-Wesley, 1994).
0 commit comments