BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_removecv.h
Go to the documentation of this file.
1/// @file bslmf_removecv.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslmf_removecv.h -*-C++-*-
8#ifndef INCLUDED_BSLMF_REMOVECV
9#define INCLUDED_BSLMF_REMOVECV
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslmf_removecv bslmf_removecv
15/// @brief Provide a meta-function for removing top-level cv-qualifiers.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslmf
19/// @{
20/// @addtogroup bslmf_removecv
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslmf_removecv-purpose"> Purpose</a>
25/// * <a href="#bslmf_removecv-classes"> Classes </a>
26/// * <a href="#bslmf_removecv-description"> Description </a>
27/// * <a href="#bslmf_removecv-usage"> Usage </a>
28/// * <a href="#bslmf_removecv-example-1-removing-the-cv-qualifiers-of-a-type"> Example 1: Removing the CV-Qualifiers of a Type </a>
29///
30/// # Purpose {#bslmf_removecv-purpose}
31/// Provide a meta-function for removing top-level cv-qualifiers.
32///
33/// # Classes {#bslmf_removecv-classes}
34///
35/// - bsl::remove_cv: meta-function for removing top-level cv-qualifiers
36/// - bsl::remove_cv_t: alias to the return type of the meta-function
37///
38/// @see bslmf_addcv
39///
40/// # Description {#bslmf_removecv-description}
41/// This component defines a meta-function, `bsl::remove_cv`, and
42/// declares a `bsl::remove_cv_t` alias to the return type of the
43/// `bsl::remove_cv`, that may be used to remove any top-level cv-qualifiers
44/// (`const`-qualifier and `volatile`-qualifier) from a type.
45///
46/// `bsl::remove_cv` and `bsl::remove_cv_t` meet the requirements of the
47/// `remove_cv` template defined in the C++11 standard [meta.trans.cv].
48///
49/// ## Usage {#bslmf_removecv-usage}
50///
51///
52/// In this section we show intended use of this component.
53///
54/// ### Example 1: Removing the CV-Qualifiers of a Type {#bslmf_removecv-example-1-removing-the-cv-qualifiers-of-a-type}
55///
56///
57/// Suppose that we want to remove the cv-qualifiers from a particular type.
58///
59/// First, we create two `typedef`s -- a `const`-qualified and
60/// `volatile`-qualified type (`MyCvType`) and the same type without the
61/// cv-qualifiers (`MyType`):
62/// @code
63/// typedef int MyType;
64/// typedef const volatile int MyCvType;
65/// @endcode
66/// Now, we remove the cv-qualifiers from `MyCvType` using `bsl::remove_cv` and
67/// verify that the resulting type is the same as `MyType`:
68/// @code
69/// assert(true == (bsl::is_same<bsl::remove_cv<MyCvType>::type,
70/// MyType>::value));
71/// @endcode
72/// Finally, if the current compiler supports alias templates C++11 feature, we
73/// remove a `const`-qualified and `volatile`-qualifier from `MyCvType` using
74///`bsl::remove_cv_t` and verify that the resulting type is the same as
75/// `MyType`:
76/// @code
77/// #ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
78/// assert(true ==
79/// (bsl::is_same<bsl::remove_cv_t<MyCvType>, MyType>::value));
80/// #endif
81/// @endcode
82/// Note, that the `bsl::remove_cv_t` avoids the `::type` suffix and `typename`
83/// prefix when we want to use the result of the `bsl::remove_cv` meta-function
84/// in templates.
85/// @}
86/** @} */
87/** @} */
88
89/** @addtogroup bsl
90 * @{
91 */
92/** @addtogroup bslmf
93 * @{
94 */
95/** @addtogroup bslmf_removecv
96 * @{
97 */
98
99#include <bslscm_version.h>
100
101#include <bslmf_removeconst.h>
102#include <bslmf_removevolatile.h>
103
105
106namespace bsl {
107
108 // ================
109 // struct remove_cv
110 // ================
111
112/// This `struct` template implements the `remove_cv` meta-function defined
113/// in the C++11 standard [meta.trans.cv], providing an alias, `type`, that
114/// returns the result. `type` has the same type as the (template
115/// parameter) `t_TYPE` except that any top-level cv-qualifiers have been
116/// removed.
117template <class t_TYPE>
118struct remove_cv {
119
120 // PUBLIC TYPES
121
122 /// This `typedef` is an alias to the same type as the (template
123 /// parameter) `t_TYPE` except that any top-level cv-qualifier has been
124 /// removed.
127};
128
129#ifdef BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
130
131// ALIASES
132
133/// `remove_cv_t` is an alias to the return type of the `bsl::remove_cv`
134/// meta-function. Note, that the `remove_cv_t` avoids the `::type` suffix
135/// and `typename` prefix when we want to use the result of the
136/// meta-function in templates.
137template <class t_TYPE>
138using remove_cv_t = typename remove_cv<t_TYPE>::type;
139#endif // BSLS_COMPILERFEATURES_SUPPORT_ALIAS_TEMPLATES
140
141} // close namespace bsl
142
143#endif
144
145// ----------------------------------------------------------------------------
146// Copyright 2013 Bloomberg Finance L.P.
147//
148// Licensed under the Apache License, Version 2.0 (the "License");
149// you may not use this file except in compliance with the License.
150// You may obtain a copy of the License at
151//
152// http://www.apache.org/licenses/LICENSE-2.0
153//
154// Unless required by applicable law or agreed to in writing, software
155// distributed under the License is distributed on an "AS IS" BASIS,
156// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
157// See the License for the specific language governing permissions and
158// limitations under the License.
159// ----------------------------- END-OF-FILE ----------------------------------
160
161/** @} */
162/** @} */
163/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlb_printmethods.h:283
Definition bslmf_removeconst.h:156
Definition bslmf_removecv.h:118
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:126