BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslalg_selecttrait.h
Go to the documentation of this file.
1/// @file bslalg_selecttrait.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslalg_selecttrait.h -*-C++-*-
8#ifndef INCLUDED_BSLALG_SELECTTRAIT
9#define INCLUDED_BSLALG_SELECTTRAIT
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslalg_selecttrait bslalg_selecttrait
15/// @brief <span style="color: var(--deprecated-color-dark)">DEPRECATED:</span> Provide a meta-function to select a suitable trait on a type.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslalg
19/// @{
20/// @addtogroup bslalg_selecttrait
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslalg_selecttrait-purpose"> Purpose</a>
25/// * <a href="#bslalg_selecttrait-classes"> Classes </a>
26/// * <a href="#bslalg_selecttrait-description"> Description </a>
27/// * <a href="#bslalg_selecttrait-usage"> Usage </a>
28///
29/// # Purpose {#bslalg_selecttrait-purpose}
30/// Provide a meta-function to select a suitable trait on a type.
31///
32/// @deprecated Use @ref bslmf_selecttrait instead.
33///
34/// # Classes {#bslalg_selecttrait-classes}
35///
36/// - bslalg::SelectTrait: trait detection mechanism
37///
38/// @see
39///
40/// # Description {#bslalg_selecttrait-description}
41/// This component provides a meta-function, `bslalg::SelectTrait`,
42/// for selecting the most appropriate trait from a list of candidate traits for
43/// parameterized `TYPE`.
44///
45/// ## Usage {#bslalg_selecttrait-usage}
46///
47///
48/// @}
49/** @} */
50/** @} */
51
52/** @addtogroup bsl
53 * @{
54 */
55/** @addtogroup bslalg
56 * @{
57 */
58/** @addtogroup bslalg_selecttrait
59 * @{
60 */
61
62#include <bslscm_version.h>
63
64#include <bslalg_hastrait.h>
65#include <bslalg_typetraitnil.h>
66
68#include <bslmf_switch.h>
69
70
71
72namespace bslalg {
73
74 // =================
75 // class SelectTrait
76 // =================
77
78/// Select one trait out of several that the parameterized type `T` may
79/// possess. If `T` has the parameterized trait `TRAIT1`, then the nested
80/// `Type` is `TRAIT1`, else if `T` has an optionally parameterized
81/// `TRAIT2`, then `Type` is `TRAIT2`, etc. Also computes an integral
82/// selection constant and meta-value. If `T` has none of the parameterized
83/// `TRAIT*`, then the nested `Type` is `TypeTraitNil`.
84///
85/// See @ref bslalg_selecttrait
86template <class TYPE,
87 class TRAIT1,
88 class TRAIT2 = TypeTraitNil,
89 class TRAIT3 = TypeTraitNil,
90 class TRAIT4 = TypeTraitNil,
91 class TRAIT5 = TypeTraitNil>
93
94 // PUBLIC TYPES
95 enum {
96 /// Integral value indicating which trait was selected: 1 for
97 /// `TRAIT1`, 2 for `TRAIT2`, etc., and 0 if none were selected.
103 0)
104 };
105
106 /// The actual trait that was selected, or `TypeTraitNil` if no trait
107 /// was selected.
108 typedef typename bslmf::Switch<SELECTION,
110 TRAIT1,
111 TRAIT2,
112 TRAIT3,
113 TRAIT4,
114 TRAIT5>::Type Type;
115};
116
117} // close package namespace
118
119#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
120// ============================================================================
121// BACKWARD COMPATIBILITY
122// ============================================================================
123
124#ifdef bslalg_SelectTrait
125#undef bslalg_SelectTrait
126#endif
127/// This alias is defined for backward compatibility.
128#define bslalg_SelectTrait bslalg::SelectTrait
129#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
130
131
132
133#endif
134
135// ----------------------------------------------------------------------------
136// Copyright 2013 Bloomberg Finance L.P.
137//
138// Licensed under the Apache License, Version 2.0 (the "License");
139// you may not use this file except in compliance with the License.
140// You may obtain a copy of the License at
141//
142// http://www.apache.org/licenses/LICENSE-2.0
143//
144// Unless required by applicable law or agreed to in writing, software
145// distributed under the License is distributed on an "AS IS" BASIS,
146// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
147// See the License for the specific language governing permissions and
148// limitations under the License.
149// ----------------------------- END-OF-FILE ----------------------------------
150
151/** @} */
152/** @} */
153/** @} */
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlc_flathashmap.h:2218
Definition bslalg_hastrait.h:117
Definition bslalg_selecttrait.h:92
bslmf::Switch< SELECTION, TypeTraitNil, TRAIT1, TRAIT2, TRAIT3, TRAIT4, TRAIT5 >::Type Type
Definition bslalg_selecttrait.h:114
@ SELECTION
Definition bslalg_selecttrait.h:98
Nil trait – every type has this trait.
Definition bslalg_typetraitnil.h:80
Definition bslmf_switch.h:542