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