BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_isvoid.h
Go to the documentation of this file.
1/// @file bslmf_isvoid.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslmf_isvoid.h -*-C++-*-
8#ifndef INCLUDED_BSLMF_ISVOID
9#define INCLUDED_BSLMF_ISVOID
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslmf_isvoid bslmf_isvoid
15/// @brief Provide a compile-time check for `void` types.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslmf
19/// @{
20/// @addtogroup bslmf_isvoid
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslmf_isvoid-purpose"> Purpose</a>
25/// * <a href="#bslmf_isvoid-classes"> Classes </a>
26/// * <a href="#bslmf_isvoid-description"> Description </a>
27/// * <a href="#bslmf_isvoid-usage"> Usage </a>
28/// * <a href="#bslmf_isvoid-example-1-determine-whether-a-type-is-the-void-type"> Example 1: Determine Whether a Type is the void Type </a>
29///
30/// # Purpose {#bslmf_isvoid-purpose}
31/// Provide a compile-time check for `void` types.
32///
33/// # Classes {#bslmf_isvoid-classes}
34///
35/// - bsl::is_void: standard meta-function for determining `void` types
36/// - bsl::is_void_v: the result value of the `bsl::is_void` meta-function
37/// - bslmf::IsVoid: meta-function for determining `void` types
38///
39/// @see bslmf_integralconstant
40///
41/// # Description {#bslmf_isvoid-description}
42/// This component defines two meta-functions, `bsl::is_void` and
43/// `BloombergLP::bslmf::IsVoid` and a template variable `bsl::is_void_v`, that
44/// represents the result value of `bsl::is_void` meta-function. All these
45/// meta-functions may be used to query whether a type is the (possibly
46/// cv-qualified) `void` type.
47///
48/// `bsl::is_void` meets the requirements of the `is_void` template defined in
49/// the C++11 standard [meta.unary.cat], while `bslmf::IsVoid` was devised
50/// before `is_void` was standardized.
51///
52/// The two meta-functions are functionally equivalent. The major difference
53/// between them is that the result for `bsl::is_void` is indicated by the
54/// class member `value`, while the result for `bslmf::IsVoid` is indicated by
55/// the class member `value`.
56///
57/// Note that `bsl::is_void` should be preferred over `bslmf::IsVoid`, and in
58/// general, should be used by new components.
59///
60/// Also note that the template variable `is_void_v` is defined in the C++17
61/// standard as an inline variable. If the current compiler supports the inline
62/// variable C++17 compiler feature, `bsl::is_void_v` is defined as an
63/// `inline constexpr bool` variable. Otherwise, if the compiler supports the
64/// variable templates C++14 compiler feature, `bsl::is_void_v` is defined as a
65/// non-inline `constexpr bool` variable. See
66/// `BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES` and
67/// `BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES` macros in
68/// bsls_compilerfeatures component for details.
69///
70/// ## Usage {#bslmf_isvoid-usage}
71///
72///
73/// In this section we show intended use of this component.
74///
75/// ### Example 1: Determine Whether a Type is the void Type {#bslmf_isvoid-example-1-determine-whether-a-type-is-the-void-type}
76///
77///
78/// Suppose that we want to assert whether a particular type is the `void` type.
79///
80/// First, we create two `typedef`s -- the `void` type and another type:
81/// @code
82/// typedef int MyType;
83/// typedef void MyVoidType;
84/// @endcode
85/// Now, we instantiate the `bsl::is_void` template for each of the `typedef`s
86/// and assert the `value` static data member of each instantiation:
87/// @code
88/// assert(false == bsl::is_void<MyType>::value);
89/// assert(true == bsl::is_void<MyVoidType>::value);
90/// @endcode
91/// Note that if the current compiler supports the variable templates C++14
92/// feature, then we can re-write the snippet of code above as follows:
93/// @code
94/// #ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
95/// assert(false == bsl::is_void_v<MyType>);
96/// assert(true == bsl::is_void_v<MyVoidType>);
97/// #endif
98/// @endcode
99/// @}
100/** @} */
101/** @} */
102
103/** @addtogroup bsl
104 * @{
105 */
106/** @addtogroup bslmf
107 * @{
108 */
109/** @addtogroup bslmf_isvoid
110 * @{
111 */
112
113#include <bslscm_version.h>
114
116
118#include <bsls_keyword.h>
119
120#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
122#include <bslmf_removecv.h>
123#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
124
125
126namespace bsl {
127
128 // ==============
129 // struct is_void
130 // ==============
131
132/// This `struct` template implements the `is_void` meta-function defined in
133/// the C++11 standard [meta.unary.cat] to determine if the (template
134/// parameter) `t_TYPE` is the (possibly cv-qualified) `void` type. This
135/// `struct` derives from `bsl::true_type` if `t_TYPE` is the `void` type,
136/// and `bsl::false_type` otherwise.
137template <class t_TYPE>
139};
140
141/// This partial specialization of `is_void` derives from `bsl::true_type`
142/// for when the (template parameter) `t_TYPE` is `void`.
143template <>
144struct is_void<void> : true_type {
145};
146
147/// This partial specialization of `is_void` derives from `bsl::true_type`
148/// for when the (template parameter) `t_TYPE` is `const void`.
149template <>
150struct is_void<const void> : true_type {
151};
152
153/// This partial specialization of `is_void` derives from `bsl::true_type`
154/// for when the (template parameter) `t_TYPE` is `volatile void`.
155template <>
156struct is_void<volatile void> : true_type {
157};
158
159/// This partial specialization of `is_void` derives from `bsl::true_type`
160/// for when the (template parameter) `t_TYPE` is `const volatile void`.
161template <>
162struct is_void<const volatile void> : bsl::true_type {
163};
164
165#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
166/// This template variable represents the result value of the `bsl::is_void`
167/// meta-function.
168template <class t_TYPE>
170#endif
171
172} // close namespace bsl
173
174
175namespace bslmf {
176
177 // ===================
178 // struct bslmf_IsVoid
179 // ===================
180
181/// This `struct` template implements a meta-function to determine if the
182/// (template parameter) `t_TYPE` is the (possibly cv-qualified) `void`
183/// type. This `struct` derives from `bsl::true_type` if `t_TYPE` is the
184/// `void` type, and `bsl::false_type` otherwise.
185///
186/// Note that although this `struct` is functionally equivalent to
187/// `bsl::is_void`, and the use of `bsl::is_void` should be preferred.
188template <class t_TYPE>
189struct IsVoid : bsl::is_void<t_TYPE>::type {
190};
191
192} // close package namespace
193
194
195#endif
196
197// ----------------------------------------------------------------------------
198// Copyright 2013 Bloomberg Finance L.P.
199//
200// Licensed under the Apache License, Version 2.0 (the "License");
201// you may not use this file except in compliance with the License.
202// You may obtain a copy of the License at
203//
204// http://www.apache.org/licenses/LICENSE-2.0
205//
206// Unless required by applicable law or agreed to in writing, software
207// distributed under the License is distributed on an "AS IS" BASIS,
208// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209// See the License for the specific language governing permissions and
210// limitations under the License.
211// ----------------------------- END-OF-FILE ----------------------------------
212
213/** @} */
214/** @} */
215/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_INLINE_VARIABLE
Definition bsls_keyword.h:623
Definition bdlb_printmethods.h:283
Definition bdlbb_blob.h:576
Definition bslmf_integralconstant.h:244
Definition bslmf_isvoid.h:138
Definition bslmf_isvoid.h:189