BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsltf_convertiblevaluewrapper.h
Go to the documentation of this file.
1/// @file bsltf_convertiblevaluewrapper.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsltf_convertiblevaluewrapper.h -*-C++-*-
8#ifndef INCLUDED_BSLTF_CONVERTIBLEVALUEWRAPPER
9#define INCLUDED_BSLTF_CONVERTIBLEVALUEWRAPPER
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsltf_convertiblevaluewrapper bsltf_convertiblevaluewrapper
15/// @brief Provide a wrapper class, convertible to a supplied value.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsltf
19/// @{
20/// @addtogroup bsltf_convertiblevaluewrapper
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsltf_convertiblevaluewrapper-purpose"> Purpose</a>
25/// * <a href="#bsltf_convertiblevaluewrapper-classes"> Classes </a>
26/// * <a href="#bsltf_convertiblevaluewrapper-description"> Description </a>
27/// * <a href="#bsltf_convertiblevaluewrapper-usage"> Usage </a>
28/// * <a href="#bsltf_convertiblevaluewrapper-example-1-tbd"> Example 1: TBD </a>
29///
30/// # Purpose {#bsltf_convertiblevaluewrapper-purpose}
31/// Provide a wrapper class, convertible to a supplied value.
32///
33/// # Classes {#bsltf_convertiblevaluewrapper-classes}
34///
35/// - bsltf::ConvertibleValueWrapper: wrapper of a value-semantic class
36///
37/// @see bsltf_templatetestfacility
38///
39/// # Description {#bsltf_convertiblevaluewrapper-description}
40/// This component provides a `struct` that holds an object of a
41/// template parameter type, and provides implicit conversions to, and from,
42/// that type. A `bsltf::ConvertibleValueWrapper` facilitates testing of
43/// function templates whose contract requires a type that is "convertible to
44/// the specified type". It also ensures that this uses up the one user-defined
45/// conversion in permitted in the conversion sequence, rather than accidentally
46/// relying on a built-in conversion such as type promotion.
47///
48/// ## Usage {#bsltf_convertiblevaluewrapper-usage}
49///
50///
51/// This section illustrates intended use of this component.
52///
53/// ### Example 1: TBD {#bsltf_convertiblevaluewrapper-example-1-tbd}
54///
55///
56/// @}
57/** @} */
58/** @} */
59
60/** @addtogroup bsl
61 * @{
62 */
63/** @addtogroup bsltf
64 * @{
65 */
66/** @addtogroup bsltf_convertiblevaluewrapper
67 * @{
68 */
69
70#include <bslscm_version.h>
71
72
73
74namespace bsltf {
75
76 // =============================
77 // class ConvertibleValueWrapper
78 // =============================
79
80/// This class provides a wrapper around an object of the specified
81/// (template parameter) `TYPE`. `TYPE` shall be CopyConstructible. If
82/// `TYPE` is a value-semantic type, then this class will also be value
83/// semantic. Objects of this type are implicitly convertible to and from
84/// objects of the specified `TYPE`.
85///
86/// See @ref bsltf_convertiblevaluewrapper
87template <class TYPE>
89
90 private:
91 // DATA
92 TYPE d_value;
93
94 public:
95 // CREATORS
96
97 /// Create an object wrapping the specified `value`.
98 ConvertibleValueWrapper(const TYPE& value); // IMPLICIT
99
100 // MANIPULATORS
101
102 /// Return a reference to the (modifiable) wrapped value.
103 operator TYPE&();
104
105 // ACCESSORS
106
107 /// Return a reference to the (non-modifiable) wrapped value.
108 operator const TYPE&() const;
109};
110
111
112// ============================================================================
113// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
114// ============================================================================
115
116
117 // -----------------------------
118 // class ConvertibleValueWrapper
119 // -----------------------------
120
121// CREATORS
122template <class TYPE>
123inline
125: d_value(value)
126{
127}
128
129template <class TYPE>
130inline
132{
133 return d_value;
134}
135
136// ACCESSORS
137template <class TYPE>
138inline
140{
141 return d_value;
142}
143
144} // close package namespace
145
146
147#endif
148
149// ----------------------------------------------------------------------------
150// Copyright 2013 Bloomberg Finance L.P.
151//
152// Licensed under the Apache License, Version 2.0 (the "License");
153// you may not use this file except in compliance with the License.
154// You may obtain a copy of the License at
155//
156// http://www.apache.org/licenses/LICENSE-2.0
157//
158// Unless required by applicable law or agreed to in writing, software
159// distributed under the License is distributed on an "AS IS" BASIS,
160// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
161// See the License for the specific language governing permissions and
162// limitations under the License.
163// ----------------------------- END-OF-FILE ----------------------------------
164
165/** @} */
166/** @} */
167/** @} */
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bsltf_allocargumenttype.h:92
Definition bsltf_convertiblevaluewrapper.h:88
ConvertibleValueWrapper(const TYPE &value)
Create an object wrapping the specified value.
Definition bsltf_convertiblevaluewrapper.h:124