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
>
12
BSLS_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
58
#include <
bsls_compilerfeatures.h
>
59
#include <
bsls_keyword.h
>
60
#include <
bsls_libraryfeatures.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
68
namespace
bsl
{
69
using
std::monostate;
70
}
// close namespace bsl
71
#else
72
namespace
bsl
{
73
// ===============
74
// struct monostate
75
// ===============
76
77
struct
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.
86
BSLS_KEYWORD_CONSTEXPR
bool
operator==(
monostate
,
87
monostate
)
BSLS_KEYWORD_NOEXCEPT
;
88
BSLS_KEYWORD_CONSTEXPR
bool
operator!=(
monostate
,
89
monostate
)
BSLS_KEYWORD_NOEXCEPT
;
90
BSLS_KEYWORD_CONSTEXPR
bool
operator<(
monostate
,
91
monostate
)
BSLS_KEYWORD_NOEXCEPT
;
92
BSLS_KEYWORD_CONSTEXPR
bool
operator>(
monostate
,
93
monostate
)
BSLS_KEYWORD_NOEXCEPT
;
94
BSLS_KEYWORD_CONSTEXPR
bool
operator<=(
monostate
,
95
monostate
)
BSLS_KEYWORD_NOEXCEPT
;
96
BSLS_KEYWORD_CONSTEXPR
bool
operator>=(
monostate
,
97
monostate
)
BSLS_KEYWORD_NOEXCEPT
;
98
99
/// Pass a `monostate` to the specified `hashAlg`, where `hashAlg` is a
100
/// hashing algorithm.
101
template
<
class
t_HASHALG>
102
void
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
110
namespace
bsl
{
111
112
inline
BSLS_KEYWORD_CONSTEXPR
113
bool
operator==(
monostate
,
monostate
)
BSLS_KEYWORD_NOEXCEPT
114
{
115
return
true
;
116
}
117
118
inline
BSLS_KEYWORD_CONSTEXPR
119
bool
operator!=(
monostate
,
monostate
)
BSLS_KEYWORD_NOEXCEPT
120
{
121
return
false
;
122
}
123
124
inline
BSLS_KEYWORD_CONSTEXPR
125
bool
operator<(
monostate
,
monostate
)
BSLS_KEYWORD_NOEXCEPT
126
{
127
return
false
;
128
}
129
130
inline
BSLS_KEYWORD_CONSTEXPR
131
bool
operator>(
monostate
,
monostate
)
BSLS_KEYWORD_NOEXCEPT
132
{
133
return
false
;
134
}
135
136
inline
BSLS_KEYWORD_CONSTEXPR
137
bool
operator<=(
monostate
,
monostate
)
BSLS_KEYWORD_NOEXCEPT
138
{
139
return
true
;
140
}
141
142
inline
BSLS_KEYWORD_CONSTEXPR
143
bool
operator>=(
monostate
,
monostate
)
BSLS_KEYWORD_NOEXCEPT
144
{
145
return
true
;
146
}
147
148
template
<
class
t_HASHALG>
149
void
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
/** @} */
bslh_hashvariant.h
bsls_compilerfeatures.h
bsls_ident.h
bsls_keyword.h
bsls_libraryfeatures.h
BSLS_IDENT
#define BSLS_IDENT(str)
Definition
bsls_ident.h:195
BSLS_KEYWORD_CONSTEXPR
#define BSLS_KEYWORD_CONSTEXPR
Definition
bsls_keyword.h:588
BSLS_KEYWORD_NOEXCEPT
#define BSLS_KEYWORD_NOEXCEPT
Definition
bsls_keyword.h:632
bsl
Definition
bdlb_printmethods.h:283
bsl::hashAppend
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const array< TYPE, SIZE > &input)
Pass the specified input to the specified hashAlgorithm
Definition
bslstl_array.h:950
bsl::monostate
Definition
bslstl_monostate.h:77
doxygen_input
bde
groups
bsl
bslstl
bslstl_monostate.h
Generated by
1.9.8