BDE 4.14.0 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 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`.
84template <class TYPE,
85 class TRAIT1,
86 class TRAIT2 = TypeTraitNil,
87 class TRAIT3 = TypeTraitNil,
88 class TRAIT4 = TypeTraitNil,
89 class TRAIT5 = TypeTraitNil>
91
92 // PUBLIC TYPES
93 enum {
94 /// Integral value indicating which trait was selected: 1 for
95 /// `TRAIT1`, 2 for `TRAIT2`, etc., and 0 if none were selected.
101 0)
102 };
103
104 /// The actual trait that was selected, or `TypeTraitNil` if no trait
105 /// was selected.
106 typedef typename bslmf::Switch<SELECTION,
108 TRAIT1,
109 TRAIT2,
110 TRAIT3,
111 TRAIT4,
112 TRAIT5>::Type Type;
113};
114
115} // close package namespace
116
117#ifndef BDE_OPENSOURCE_PUBLICATION // BACKWARD_COMPATIBILITY
118// ============================================================================
119// BACKWARD COMPATIBILITY
120// ============================================================================
121
122#ifdef bslalg_SelectTrait
123#undef bslalg_SelectTrait
124#endif
125/// This alias is defined for backward compatibility.
126#define bslalg_SelectTrait bslalg::SelectTrait
127#endif // BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
128
129
130
131#endif
132
133// ----------------------------------------------------------------------------
134// Copyright 2013 Bloomberg Finance L.P.
135//
136// Licensed under the Apache License, Version 2.0 (the "License");
137// you may not use this file except in compliance with the License.
138// You may obtain a copy of the License at
139//
140// http://www.apache.org/licenses/LICENSE-2.0
141//
142// Unless required by applicable law or agreed to in writing, software
143// distributed under the License is distributed on an "AS IS" BASIS,
144// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
145// See the License for the specific language governing permissions and
146// limitations under the License.
147// ----------------------------- END-OF-FILE ----------------------------------
148
149/** @} */
150/** @} */
151/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlc_flathashmap.h:1805
Definition bslalg_hastrait.h:117
Definition bslalg_selecttrait.h:90
bslmf::Switch< SELECTION, TypeTraitNil, TRAIT1, TRAIT2, TRAIT3, TRAIT4, TRAIT5 >::Type Type
Definition bslalg_selecttrait.h:112
@ SELECTION
Definition bslalg_selecttrait.h:96
Nil trait – every type has this trait.
Definition bslalg_typetraitnil.h:80
Definition bslmf_switch.h:537