BDE 4.14.0 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`.
85template <class TYPE>
87
88 private:
89 // DATA
90 TYPE d_value;
91
92 public:
93 // CREATORS
94
95 /// Create an object wrapping the specified `value`.
96 ConvertibleValueWrapper(const TYPE& value); // IMPLICIT
97
98 // MANIPULATORS
99
100 /// Return a reference to the (modifiable) wrapped value.
101 operator TYPE&();
102
103 // ACCESSORS
104
105 /// Return a reference to the (non-modifiable) wrapped value.
106 operator const TYPE&() const;
107};
108
109
110// ============================================================================
111// INLINE AND TEMPLATE FUNCTION IMPLEMENTATIONS
112// ============================================================================
113
114
115 // -----------------------------
116 // class ConvertibleValueWrapper
117 // -----------------------------
118
119// CREATORS
120template <class TYPE>
121inline
123: d_value(value)
124{
125}
126
127template <class TYPE>
128inline
130{
131 return d_value;
132}
133
134// ACCESSORS
135template <class TYPE>
136inline
138{
139 return d_value;
140}
141
142} // close package namespace
143
144
145#endif
146
147// ----------------------------------------------------------------------------
148// Copyright 2013 Bloomberg Finance L.P.
149//
150// Licensed under the Apache License, Version 2.0 (the "License");
151// you may not use this file except in compliance with the License.
152// You may obtain a copy of the License at
153//
154// http://www.apache.org/licenses/LICENSE-2.0
155//
156// Unless required by applicable law or agreed to in writing, software
157// distributed under the License is distributed on an "AS IS" BASIS,
158// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159// See the License for the specific language governing permissions and
160// limitations under the License.
161// ----------------------------- END-OF-FILE ----------------------------------
162
163/** @} */
164/** @} */
165/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bsltf_allocargumenttype.h:92
Definition bsltf_convertiblevaluewrapper.h:86
ConvertibleValueWrapper(const TYPE &value)
Create an object wrapping the specified value.
Definition bsltf_convertiblevaluewrapper.h:122