BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslalg_hastrait.h
Go to the documentation of this file.
1
/// @file bslalg_hastrait.h
2
///
3
/// The content of this file has been pre-processed for Doxygen.
4
///
5
6
7
// bslalg_hastrait.h -*-C++-*-
8
#ifndef INCLUDED_BSLALG_HASTRAIT
9
#define INCLUDED_BSLALG_HASTRAIT
10
11
#include <
bsls_ident.h
>
12
BSLS_IDENT
(
"$Id: $"
)
13
14
/// @defgroup bslalg_hastrait bslalg_hastrait
15
/// @brief <span style="color: var(--deprecated-color-dark)">DEPRECATED:</span> Provide a meta-function to detect if a type has a given trait.
16
/// @addtogroup bsl
17
/// @{
18
/// @addtogroup bslalg
19
/// @{
20
/// @addtogroup bslalg_hastrait
21
/// @{
22
///
23
/// <h1> Outline </h1>
24
/// * <a href="#bslalg_hastrait-purpose"> Purpose</a>
25
/// * <a href="#bslalg_hastrait-classes"> Classes </a>
26
/// * <a href="#bslalg_hastrait-description"> Description </a>
27
/// * <a href="#bslalg_hastrait-usage"> Usage </a>
28
///
29
/// # Purpose {#bslalg_hastrait-purpose}
30
/// Provide a meta-function to detect if a type has a given trait.
31
///
32
/// @deprecated Do not use.
33
///
34
/// # Classes {#bslalg_hastrait-classes}
35
///
36
/// - bslalg::HasTrait: legacy mechanism for detecting type traits
37
///
38
/// @see bslalg_typetraits, bslmf_integralconstant
39
///
40
/// # Description {#bslalg_hastrait-description}
41
/// This component provides a meta-function, `bslalg::HasTrait`,
42
/// that is a legacy mechanism for detecting traits. `bslalg::HasTrait` takes
43
/// two template parameters, `TYPE` and `TRAIT`.
44
/// `bslalg::HasTrait<TYPE, TRAIT>` inherits from `bsl::true_type` if the
45
/// (template parameter) `TYPE` has the (template parameter) `TRAIT`, and
46
/// inherits from `bsl::false_type` otherwise.
47
///
48
/// `bslalg::HasTrait` is *not* a general-purpose trait detection facility. It
49
/// is intended to be used in conjunction with the legacy (deprecated) `bslalg`
50
/// traits only. In particular, the type supplied to `bslalg::HasTrait` as the
51
/// `TRAIT` template parameter *must* be a `bslalg` trait, for example,
52
/// `bslalg::TypeTraitUsesBslmaAllocator`. Supplying anything else for `TRAIT`
53
/// will (more than likely) fail to compile. For example, the following errant
54
/// use of `bslalg::HasTrait` will definitely fail to compile:
55
/// @code
56
/// bslalg::HasTrait<Foo, bsl::is_trivially_default_constructible>'
57
/// @endcode
58
/// See @ref bslalg_typetraits for a complete list of the `bslalg` traits that are
59
/// supported by `bslalg::HasTrait`.
60
///
61
/// In lieu of the deprecated `bslalg` traits, the newer traits intended to
62
/// replace them should be used instead. These successor traits are typically
63
/// defined in `bslmf` (two exceptions are `bslma::UsesBslmaAllocator` and
64
/// `bslalg::HasStlIterators`). `bslalg::HasTrait` and the `bslalg` traits that
65
/// it supports are written in such a way that `bslalg::HasTrait` will correctly
66
/// detect whether a type has a given trait regardless of whether the trait is
67
/// ascribed to the type using the deprecated `BSLALG_DECLARE_NESTED_TRAITS*` or
68
/// `BSLMF_NESTED_TRAIT_DECLARATION` macros (see @ref bslalg_typetraits and
69
/// @ref bslmf_nestedtraitdeclaration , respectively), or whether the (preferred)
70
/// C++11 idiom for defining traits is used (see @ref bslmf_detectnestedtrait ). In
71
/// this way, `bslalg::HasTrait` provides a "bridge" between legacy `bslalg`
72
/// type traits and their replacements that facilitates the migration to the
73
/// newer traits.
74
///
75
/// ## Usage {#bslalg_hastrait-usage}
76
///
77
///
78
/// No Usage example is provided since this component is deprecated.
79
/// @}
80
/** @} */
81
/** @} */
82
83
/** @addtogroup bsl
84
* @{
85
*/
86
/** @addtogroup bslalg
87
* @{
88
*/
89
/** @addtogroup bslalg_hastrait
90
* @{
91
*/
92
93
#include <bslscm_version.h>
94
95
#include <
bslmf_integralconstant.h
>
96
#include <
bslmf_removecv.h
>
97
98
#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
99
#include <
bslmf_isconvertible.h
>
100
#include <
bslmf_removecvq.h
>
101
#endif
// BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
102
103
104
namespace
bslalg
{
105
106
// ===============
107
// struct HasTrait
108
// ===============
109
110
/// This meta-function evaluates to `bsl::true_type` if the (template
111
/// parameter) `TYPE` has the (template parameter) `TRAIT`, and to
112
/// `bsl::false_type` otherwise.
113
template
<
class
TYPE,
class
TRAIT>
114
struct
HasTrait
:
public
bsl::integral_constant
<
115
bool,
116
TRAIT::template Metafunction<
117
typename bsl::remove_cv<TYPE>::type>::value> {
118
};
119
120
}
// close package namespace
121
122
#ifndef BDE_OPENSOURCE_PUBLICATION
// BACKWARD_COMPATIBILITY
123
// ============================================================================
124
// BACKWARD COMPATIBILITY
125
// ============================================================================
126
127
#ifdef bslalg_HasTrait
128
#undef bslalg_HasTrait
129
#endif
130
/// This alias is defined for backward compatibility.
131
#define bslalg_HasTrait bslalg::HasTrait
132
#endif
// BDE_OPENSOURCE_PUBLICATION -- BACKWARD_COMPATIBILITY
133
134
135
136
#endif
137
138
// ----------------------------------------------------------------------------
139
// Copyright 2013 Bloomberg Finance L.P.
140
//
141
// Licensed under the Apache License, Version 2.0 (the "License");
142
// you may not use this file except in compliance with the License.
143
// You may obtain a copy of the License at
144
//
145
// http://www.apache.org/licenses/LICENSE-2.0
146
//
147
// Unless required by applicable law or agreed to in writing, software
148
// distributed under the License is distributed on an "AS IS" BASIS,
149
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
150
// See the License for the specific language governing permissions and
151
// limitations under the License.
152
// ----------------------------- END-OF-FILE ----------------------------------
153
154
/** @} */
155
/** @} */
156
/** @} */
bslmf_integralconstant.h
bslmf_isconvertible.h
bslmf_removecv.h
bslmf_removecvq.h
bsls_ident.h
BSLS_IDENT
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition
bsls_ident.h:238
bslalg
Definition
bdlc_flathashmap.h:2218
bsl::integral_constant
Definition
bslmf_integralconstant.h:261
bslalg::HasTrait
Definition
bslalg_hastrait.h:117
doxygen_input
bde
groups
bsl
bslalg
bslalg_hastrait.h
Generated by
1.9.8