BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_monostate.h
Go to the documentation of this file.
1/// @file bslstl_monostate.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_monostate.h -*-C++-*-
8#ifndef INCLUDED_BSLSTL_MONOSTATE
9#define INCLUDED_BSLSTL_MONOSTATE
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslstl_monostate bslstl_monostate
15/// @brief Provide a default constructible alternative for `bsl::variant`.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_monostate
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_monostate-purpose"> Purpose</a>
25/// * <a href="#bslstl_monostate-classes"> Classes </a>
26/// * <a href="#bslstl_monostate-description"> Description </a>
27///
28/// # Purpose {#bslstl_monostate-purpose}
29/// Provide a default constructible alternative for `bsl::variant`.
30///
31/// # Classes {#bslstl_monostate-classes}
32///
33/// - bsl::monostate: default constructible `bsl::variant` first alternative
34///
35/// @see bslstl_variant
36///
37/// # Description {#bslstl_monostate-description}
38/// This component provides a `bsl::monostate` class. This class
39/// can serve as a first alternative type for a `bsl::variant` to make the
40/// `bsl::variant` type default constructible.
41/// @}
42/** @} */
43/** @} */
44
45/** @addtogroup bsl
46 * @{
47 */
48/** @addtogroup bslstl
49 * @{
50 */
51/** @addtogroup bslstl_monostate
52 * @{
53 */
54
55
56#include <bslscm_version.h>
57
59#include <bsls_keyword.h>
61
62#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
63#include <variant> // for 'std::monostate'
64#include <bslh_hashvariant.h>
65#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
66
67#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
68namespace bsl {
69using std::monostate;
70} // close namespace bsl
71#else
72namespace bsl {
73 // ===============
74 // struct monostate
75 // ===============
76
77struct monostate {
78
79};
80
81// FREE OPERATORS
82
83/// Compare two `monostate` objects. Since `monostate` only has one value,
84/// the result is `true` for the `==`, `<=`, and `>=` operators, and `false`
85/// for the `!=`, `<`, and `>` operators.
86BSLS_KEYWORD_CONSTEXPR bool operator==(monostate,
88BSLS_KEYWORD_CONSTEXPR bool operator!=(monostate,
94BSLS_KEYWORD_CONSTEXPR bool operator<=(monostate,
96BSLS_KEYWORD_CONSTEXPR bool operator>=(monostate,
98
99/// Pass a `monostate` to the specified `hashAlg`, where `hashAlg` is a
100/// hashing algorithm.
101template <class t_HASHALG>
102void hashAppend(t_HASHALG& hashAlg, const monostate&);
103} // close namespace bsl
104#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
105
106// ============================================================================
107// INLINE DEFINITIONS
108// ============================================================================
109#ifndef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
110namespace bsl {
111
114{
115 return true;
116}
117
120{
121 return false;
122}
123
126{
127 return false;
128}
129
132{
133 return false;
134}
135
138{
139 return true;
140}
141
144{
145 return true;
146}
147
148template <class t_HASHALG>
149void hashAppend(t_HASHALG& hashAlg, const monostate&)
150{
151 hashAppend(hashAlg, -7777);
152}
153} // close namespace bsl
154#endif // BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
155#endif // INCLUDED_BSLSTL_MONOSTATE
156
157// ----------------------------------------------------------------------------
158// Copyright 2023 Bloomberg Finance L.P.
159//
160// Licensed under the Apache License, Version 2.0 (the "License");
161// you may not use this file except in compliance with the License.
162// You may obtain a copy of the License at
163//
164// http://www.apache.org/licenses/LICENSE-2.0
165//
166// Unless required by applicable law or agreed to in writing, software
167// distributed under the License is distributed on an "AS IS" BASIS,
168// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
169// See the License for the specific language governing permissions and
170// limitations under the License.
171// ----------------------------- END-OF-FILE ----------------------------------
172
173/** @} */
174/** @} */
175/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
Definition bdlb_printmethods.h:283
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const array< TYPE, SIZE > &input)
Pass the specified input to the specified hashAlgorithm
Definition bslstl_array.h:950
Definition bslstl_monostate.h:77