BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslalg_scalardestructionprimitives.h
Go to the documentation of this file.
1/// @file bslalg_scalardestructionprimitives.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslalg_scalardestructionprimitives.h -*-C++-*-
8#ifndef INCLUDED_BSLALG_SCALARDESTRUCTIONPRIMITIVES
9#define INCLUDED_BSLALG_SCALARDESTRUCTIONPRIMITIVES
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslalg_scalardestructionprimitives bslalg_scalardestructionprimitives
15/// @brief Provide primitive algorithms that destroy scalars.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslalg
19/// @{
20/// @addtogroup bslalg_scalardestructionprimitives
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslalg_scalardestructionprimitives-purpose"> Purpose</a>
25/// * <a href="#bslalg_scalardestructionprimitives-classes"> Classes </a>
26/// * <a href="#bslalg_scalardestructionprimitives-description"> Description </a>
27/// * <a href="#bslalg_scalardestructionprimitives-usage"> Usage </a>
28/// * <a href="#bslalg_scalardestructionprimitives-example-1-destroy-int-and-an-integer-wrapper"> Example 1: Destroy int and an Integer Wrapper </a>
29///
30/// # Purpose {#bslalg_scalardestructionprimitives-purpose}
31/// Provide primitive algorithms that destroy scalars.
32///
33/// @deprecated Use @ref bslma_destructionutil instead.
34///
35/// # Classes {#bslalg_scalardestructionprimitives-classes}
36///
37/// - bslalg::ScalarDestructionPrimitives: namespace for scalar algorithms
38///
39/// @see bslalg_scalarprimitives, bslalg_typetraits
40///
41/// # Description {#bslalg_scalardestructionprimitives-description}
42/// This component provides utilities to destroy scalars with a
43/// uniform interface, but select a different implementation according to the
44/// traits possessed by the underlying type.
45///
46/// The trait under consideration by this component is:
47/// @code
48/// Trait Note
49/// ------------------------------- -------------------------------------
50/// bslmf::IsBitwiseCopyable Expressed in English as "TYPE has the
51/// bit-wise copyable trait", or "TYPE is
52/// bit-wise copyable", this trait also
53/// implies that destructor calls can be
54/// elided with no effect on observable
55/// behavior.
56///
57/// @endcode
58///
59/// ## Usage {#bslalg_scalardestructionprimitives-usage}
60///
61///
62/// In this section we show intended use of this component. Note that this
63/// component is for use by the `bslstl` package. Other clients should use the
64/// STL algorithms (in header `<algorithm>` and `<memory>`).
65///
66/// ### Example 1: Destroy int and an Integer Wrapper {#bslalg_scalardestructionprimitives-example-1-destroy-int-and-an-integer-wrapper}
67///
68///
69/// In this example, we will use `bslalg::ScalarDestructionPrimitives` to
70/// destroy both a scalar integer and a `MyInteger` type object. Calling the
71/// `destroy` method on a scalar integer is a no-op while calling the `destroy`
72/// method on an object of `MyInteger` class invokes the destructor of the
73/// object.
74///
75/// First, we define a `MyInteger` class that represents an integer value:
76/// @code
77/// class MyInteger {
78/// // This class represents an integer value.
79///
80/// // DATA
81/// int d_intValue; // integer value
82///
83/// public:
84/// // CREATORS
85/// MyInteger();
86/// // Create a 'MyInteger' object having integer value '0'.
87///
88/// explicit MyInteger(int value);
89/// // Create a 'MyInteger' object having the specified 'value'.
90///
91/// ~MyInteger();
92/// // Destroy this object.
93///
94/// // ACCESSORS
95/// int getValue() const;
96/// };
97/// @endcode
98/// Then, we create an object, `myInteger`, of type `MyInteger`:
99/// @code
100/// bsls::ObjectBuffer<MyInteger> buffer;
101/// MyInteger *myInteger = &buffer.object();
102/// new (myInteger) MyInteger(1);
103/// @endcode
104/// Notice that we use an `ObjectBuffer` to allow us to safely invoke the
105/// destructor explicitly.
106///
107/// Now, we define a primitive integer:
108/// @code
109/// int scalarInteger = 2;
110/// @endcode
111/// Finally, we use the uniform `bslalg::ScalarDestructionPrimitives:destroy`
112/// method to destroy both `myInteger` and `scalarInteger`:
113/// @code
114/// bslalg::ScalarDestructionPrimitives::destroy(myInteger);
115/// bslalg::ScalarDestructionPrimitives::destroy(&scalarInteger);
116/// @endcode
117/// @}
118/** @} */
119/** @} */
120
121/** @addtogroup bsl
122 * @{
123 */
124/** @addtogroup bslalg
125 * @{
126 */
127/** @addtogroup bslalg_scalardestructionprimitives
128 * @{
129 */
130
131#include <bslscm_version.h>
132
134
135#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
136
137#include <cstring> // 'memset', 'memcpy', 'memmove'
138#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
139
140
141namespace bslalg {
142
143/// This alias is defined for backward compatibility.
145
146} // close package namespace
147
148#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
149// ============================================================================
150// BACKWARD COMPATIBILITY
151// ============================================================================
152
153/// This alias is defined for backward compatibility.
155#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
156
157
158
159#endif
160
161// ----------------------------------------------------------------------------
162// Copyright 2013 Bloomberg Finance L.P.
163//
164// Licensed under the Apache License, Version 2.0 (the "License");
165// you may not use this file except in compliance with the License.
166// You may obtain a copy of the License at
167//
168// http://www.apache.org/licenses/LICENSE-2.0
169//
170// Unless required by applicable law or agreed to in writing, software
171// distributed under the License is distributed on an "AS IS" BASIS,
172// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
173// See the License for the specific language governing permissions and
174// limitations under the License.
175// ----------------------------- END-OF-FILE ----------------------------------
176
177/** @} */
178/** @} */
179/** @} */
bslalg::ScalarDestructionPrimitives bslalg_ScalarDestructionPrimitives
This alias is defined for backward compatibility.
Definition bslalg_scalardestructionprimitives.h:154
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlc_flathashmap.h:1805
bslma::DestructionUtil ScalarDestructionPrimitives
This alias is defined for backward compatibility.
Definition bslalg_scalardestructionprimitives.h:144
Definition bslma_destructionutil.h:153