BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_isrvaluereference.h
Go to the documentation of this file.
1/// @file bslmf_isrvaluereference.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslmf_isrvaluereference.h -*-C++-*-
8#ifndef INCLUDED_BSLMF_ISRVALUEREFERENCE
9#define INCLUDED_BSLMF_ISRVALUEREFERENCE
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslmf_isrvaluereference bslmf_isrvaluereference
15/// @brief Provide a compile-time check for rvalue reference types.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslmf
19/// @{
20/// @addtogroup bslmf_isrvaluereference
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslmf_isrvaluereference-purpose"> Purpose</a>
25/// * <a href="#bslmf_isrvaluereference-classes"> Classes </a>
26/// * <a href="#bslmf_isrvaluereference-description"> Description </a>
27/// * <a href="#bslmf_isrvaluereference-usage"> Usage </a>
28/// * <a href="#bslmf_isrvaluereference-example-1-verify-rvalue-reference-types"> Example 1: Verify Rvalue Reference Types </a>
29///
30/// # Purpose {#bslmf_isrvaluereference-purpose}
31/// Provide a compile-time check for rvalue reference types.
32///
33/// # Classes {#bslmf_isrvaluereference-classes}
34///
35/// - bsl::is_rvalue_reference: standard meta-function for rvalue reference types
36/// - bsl::is_rvalue_reference_v: the result value of the standard meta-function
37///
38/// @see bslmf_integralconstant
39///
40/// # Description {#bslmf_isrvaluereference-description}
41/// This component defines a meta-function,
42/// `bsl::is_rvalue_reference` and a template variable
43/// `bsl::is_rvalue_reference_v`, that represents the result value of the
44/// `bsl::is_rvalue_reference` meta-function, that may be used to query whether
45/// a type is an rvalue reference type.
46///
47/// `bsl::is_rvalue_reference` meets the requirements of the
48/// `is_rvalue_reference` template defined in the C++11 standard
49/// [meta.unary.cat].
50///
51/// Note that the template variable `is_rvalue_reference_v` is defined in the
52/// C++17 standard as an inline variable. If the current compiler supports the
53/// inline variable C++17 compiler feature, `bsl::is_rvalue_reference_v` is
54/// defined as an `inline constexpr bool` variable. Otherwise, if the compiler
55/// supports the variable templates C++14 compiler feature,
56/// `bsl::is_rvalue_reference_v` is defined as a non-inline `constexpr bool`
57/// variable. See `BSLS_COMPILERFEATURES_SUPPORT_INLINE_VARIABLES` and
58/// `BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES` macros in
59/// bsls_compilerfeatures component for details.
60///
61/// ## Usage {#bslmf_isrvaluereference-usage}
62///
63///
64/// In this section we show intended use of this component.
65///
66/// ### Example 1: Verify Rvalue Reference Types {#bslmf_isrvaluereference-example-1-verify-rvalue-reference-types}
67///
68///
69/// Suppose that we want to assert whether a set of types are rvalue reference
70/// types.
71///
72/// Now, we instantiate the `bsl::is_rvalue_reference` template for both a
73/// non-reference type and an rvalue reference type, and assert the `value`
74/// static data member of each instantiation:
75/// @code
76/// assert(false == bsl::is_rvalue_reference<int>::value);
77/// #if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
78/// assert(true == bsl::is_rvalue_reference<int&&>::value);
79/// #endif
80/// @endcode
81/// Note that rvalue reference is a feature introduced in the C++11 standard,
82/// and may not be supported by all compilers.
83///
84/// Also note that if the current compiler supports the variable templates C++14
85/// feature then we can re-write the snippet of code above using the
86/// `bsl::is_rvalue_reference_v` variable as follows:
87/// @code
88/// #ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
89/// assert(false == bsl::is_rvalue_reference_v<int>);
90/// assert(true == bsl::is_rvalue_reference_v<int&&>);
91/// #endif
92/// @endcode
93/// @}
94/** @} */
95/** @} */
96
97/** @addtogroup bsl
98 * @{
99 */
100/** @addtogroup bslmf
101 * @{
102 */
103/** @addtogroup bslmf_isrvaluereference
104 * @{
105 */
106
107#include <bslscm_version.h>
108
110
112#include <bsls_keyword.h>
113
114namespace bsl {
115
116 // ==========================
117 // struct is_rvalue_reference
118 // ==========================
119
120/// This `struct` template provides a meta-function to determine whether the
121/// (template parameter) `t_TYPE` is a (possibly cv-qualified) rvalue
122/// reference type. This generic default template derives from
123/// `bsl::false_type`. A template specialization is provided (below) that
124/// derives from `bsl::true_type`.
125template <class t_TYPE>
128
129#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES)
130
131/// This partial specialization of `is_rvalue_reference` derives from
132/// `bsl::true_type` for when the (template parameter) `t_TYPE` is an rvalue
133/// reference type.
134template <class t_TYPE>
135struct is_rvalue_reference<t_TYPE&&> : true_type {
136};
137
138#endif
139
140#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
141/// This template variable represents the result value of the
142/// `bsl::is_rvalue_reference` meta-function.
143template <class t_TYPE>
144BSLS_KEYWORD_INLINE_VARIABLE constexpr bool is_rvalue_reference_v =
146#endif
147
148} // close namespace bsl
149
150#endif
151
152// ----------------------------------------------------------------------------
153// Copyright 2013 Bloomberg Finance L.P.
154//
155// Licensed under the Apache License, Version 2.0 (the "License");
156// you may not use this file except in compliance with the License.
157// You may obtain a copy of the License at
158//
159// http://www.apache.org/licenses/LICENSE-2.0
160//
161// Unless required by applicable law or agreed to in writing, software
162// distributed under the License is distributed on an "AS IS" BASIS,
163// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
164// See the License for the specific language governing permissions and
165// limitations under the License.
166// ----------------------------- END-OF-FILE ----------------------------------
167
168/** @} */
169/** @} */
170/** @} */
static const t_TYPE value
Definition bslmf_integralconstant.h:258
#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 bslmf_integralconstant.h:244
Definition bslmf_isrvaluereference.h:126