BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_removecvq.h
Go to the documentation of this file.
1/// @file bslmf_removecvq.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslmf_removecvq.h -*-C++-*-
8#ifndef INCLUDED_BSLMF_REMOVECVQ
9#define INCLUDED_BSLMF_REMOVECVQ
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslmf_removecvq bslmf_removecvq
15/// @brief Provide a meta-function for removing `const`/`volatile` qualifiers.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslmf
19/// @{
20/// @addtogroup bslmf_removecvq
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslmf_removecvq-purpose"> Purpose</a>
25/// * <a href="#bslmf_removecvq-classes"> Classes </a>
26/// * <a href="#bslmf_removecvq-description"> Description </a>
27/// * <a href="#bslmf_removecvq-usage"> Usage </a>
28///
29/// # Purpose {#bslmf_removecvq-purpose}
30/// Provide a meta-function for removing `const`/`volatile` qualifiers.
31///
32/// # Classes {#bslmf_removecvq-classes}
33///
34/// - bslmf::RemoveCvq: meta-function for stripping `const`/`volatile` qualifiers
35///
36/// # Description {#bslmf_removecvq-description}
37/// This component defines a simple template structure used to
38/// strip of any top-level `const`/`volatile` qualifiers from it's single
39/// template parameter. The un-qualified type can be accessed via the `Type`
40/// member defined in `bslmf::RemoveCvq`.
41/// @code
42/// struct MyType {};
43///
44/// bslmf::RemoveCvq<int >::Type i1; // int i1;
45/// bslmf::RemoveCvq<const int >::Type i2; // int i2;
46/// bslmf::RemoveCvq<volatile int >::Type i3; // int i3;
47/// bslmf::RemoveCvq<int * >::Type i4; // int *i4;
48/// bslmf::RemoveCvq<int ** >::Type i5; // int **i5;
49/// bslmf::RemoveCvq<int *const >::Type i6; // int *i6;
50/// bslmf::RemoveCvq<int *const * >::Type i7; // int *const *i7;
51/// bslmf::RemoveCvq<int *const *const>::Type i8; // int *const *i8;
52/// bslmf::RemoveCvq<MyType >::Type m1; // MyType m1;
53/// bslmf::RemoveCvq<MyType const >::Type m2; // MyType m2;
54/// @endcode
55///
56/// ## Usage {#bslmf_removecvq-usage}
57///
58///
59/// We can make a simple template function that shows whether two objects are
60/// the same type, ignoring `const` and `volatile` qualifiers.
61///
62/// First, we create a template that will determine whether two objects are
63/// EXACTLY the same type:
64/// @code
65/// template <class t_TYPE>
66/// bool isSame(t_TYPE& a, t_TYPE& b) { return true; }
67/// template <class TYPEA, class TYPEB>
68/// bool isSame(TYPEA& a, TYPEB& b) { return false; }
69/// @endcode
70/// Next, we combine that template function with the use of `bslmf::RemoveCvq`
71/// to create a template that will determine whether two objects are the same
72/// type, ignoring `const` and `volatile` qualifiers:
73/// @code
74/// template <class TYPEA, class TYPEB>
75/// bool isSortaSame(TYPEA& a, TYPEB& b)
76/// {
77/// typename bslmf::RemoveCvq<TYPEA>::Type aa = a;
78/// typename bslmf::RemoveCvq<TYPEB>::Type bb = b;
79///
80/// return isSame(aa, bb);
81/// }
82/// @endcode
83/// Next, we use the templates
84/// @code
85/// int i = 0, j = 0;
86/// const int ci = 0, cj = 0;
87/// volatile int vi = 0, vj = 0;
88/// const volatile int cvi = 0, cvj = 0;
89///
90/// double x = 0, y = 0;
91///
92/// assert( isSame(i, j));
93/// assert( isSame(ci, cj));
94/// assert( isSame(vi, vj));
95/// assert( isSame(cvi, cvj));
96/// assert( isSame(x, y));
97///
98/// assert(! isSame(i, x));
99/// assert(! isSame(i, ci));
100/// assert(! isSame(i, vi));
101/// assert(! isSame(i, cvi));
102/// assert(! isSame(ci, vi));
103/// assert(! isSame(ci, cvi));
104/// assert(! isSame(vi, cvi));
105///
106/// assert(! isSortaSame(i, x));
107/// assert( isSortaSame(i, ci));
108/// assert( isSortaSame(i, vi));
109/// assert( isSortaSame(i, cvi));
110/// assert( isSortaSame(ci, vi));
111/// assert( isSortaSame(ci, vi));
112/// assert( isSortaSame(ci, cvi));
113/// assert( isSortaSame(vi, cvi));
114/// @endcode
115/// @}
116/** @} */
117/** @} */
118
119/** @addtogroup bsl
120 * @{
121 */
122/** @addtogroup bslmf
123 * @{
124 */
125/** @addtogroup bslmf_removecvq
126 * @{
127 */
128
129#include <bslscm_version.h>
130
131#include <bslmf_removecv.h>
132
133
134
135namespace bslmf {
136
137 // ================
138 // struct RemoveCvq
139 // ================
140
141/// This class implements a meta-function for stripping top-level
142/// const/volatile qualifiers from it's parameter type.
143template <class t_TYPE>
145{
146
148};
149
150} // close package namespace
151
152#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
153// ============================================================================
154// BACKWARD COMPATIBILITY
155// ============================================================================
156
157#ifdef bslmf_RemoveCvq
158#undef bslmf_RemoveCvq
159#endif
160/// This alias is defined for backward compatibility.
161#define bslmf_RemoveCvq bslmf::RemoveCvq
162#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
163
164
165
166#endif
167
168// ----------------------------------------------------------------------------
169// Copyright 2013 Bloomberg Finance L.P.
170//
171// Licensed under the Apache License, Version 2.0 (the "License");
172// you may not use this file except in compliance with the License.
173// You may obtain a copy of the License at
174//
175// http://www.apache.org/licenses/LICENSE-2.0
176//
177// Unless required by applicable law or agreed to in writing, software
178// distributed under the License is distributed on an "AS IS" BASIS,
179// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
180// See the License for the specific language governing permissions and
181// limitations under the License.
182// ----------------------------- END-OF-FILE ----------------------------------
183
184/** @} */
185/** @} */
186/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlbb_blob.h:576
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126
Definition bslmf_removecvq.h:145
bsl::remove_cv< t_TYPE >::type Type
Definition bslmf_removecvq.h:147