BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf_isconvertibletoany.h
Go to the documentation of this file.
1/// @file bslmf_isconvertibletoany.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslmf_isconvertibletoany.h -*-C++-*-
8#ifndef INCLUDED_BSLMF_ISCONVERTIBLETOANY
9#define INCLUDED_BSLMF_ISCONVERTIBLETOANY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslmf_isconvertibletoany bslmf_isconvertibletoany
15/// @brief Provide a compile-time check for types convertible to any type.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslmf
19/// @{
20/// @addtogroup bslmf_isconvertibletoany
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslmf_isconvertibletoany-purpose"> Purpose</a>
25/// * <a href="#bslmf_isconvertibletoany-classes"> Classes </a>
26/// * <a href="#bslmf_isconvertibletoany-description"> Description </a>
27/// * <a href="#bslmf_isconvertibletoany-usage"> Usage </a>
28/// * <a href="#bslmf_isconvertibletoany-example-1-determine-if-a-class-has-a-template-conversion-operator"> Example 1: Determine If a Class Has a Template Conversion Operator </a>
29///
30/// # Purpose {#bslmf_isconvertibletoany-purpose}
31/// Provide a compile-time check for types convertible to any type.
32///
33/// # Classes {#bslmf_isconvertibletoany-classes}
34///
35/// - bslmf::IsConvertibleToAny: meta-function for detecting conversion
36///
37/// @see bslmf_isconvertible, bslmf_integralconstant
38///
39/// # Description {#bslmf_isconvertibletoany-description}
40/// This component provides a meta-function,
41/// `bslmf::IsConvertibleToAny`, that may be used to query (at compile-time)
42/// whether a type has a templatized conversion operator allowing it to be
43/// converted to any other type.
44///
45/// ## Usage {#bslmf_isconvertibletoany-usage}
46///
47///
48/// In this section we show the intended use of this component.
49///
50/// ### Example 1: Determine If a Class Has a Template Conversion Operator {#bslmf_isconvertibletoany-example-1-determine-if-a-class-has-a-template-conversion-operator}
51///
52///
53/// Suppose that we want to assert whether a particular type has a template
54/// conversion operator.
55///
56/// First, we define a type with the template conversion operator:
57/// @code
58/// struct TypeWithTemplateConversion {
59/// template <class t_TYPE>
60/// operator t_TYPE() {
61/// return t_TYPE();
62/// }
63/// };
64/// @endcode
65/// Now, we instantiate the `bslmf::IsConvertibleToAny` template for
66/// `TypeWithTemplateConversion` and assert the `value` of the instantiation:
67/// @code
68/// assert(bslmf::IsConvertibleToAny<TypeWithTemplateConversion>::value);
69/// @endcode
70/// @}
71/** @} */
72/** @} */
73
74/** @addtogroup bsl
75 * @{
76 */
77/** @addtogroup bslmf
78 * @{
79 */
80/** @addtogroup bslmf_isconvertibletoany
81 * @{
82 */
83
84#include <bslscm_version.h>
85
87#include <bslmf_isconvertible.h>
88
89
90
91namespace bslmf {
92
93 // =========================
94 // struct IsConvertibleToAny
95 // =========================
96
97/// This class template implements a component-private meta-function to
98/// determine if the (template parameter) `t_TYPE` is convertible to any
99/// other type.
100///
101/// See @ref bslmf_isconvertibletoany
102template <class t_TYPE>
104
105 /// A type convertible to this private type must have a template
106 /// conversion operator.
107 struct UniqueType {
108 };
109
110 public:
111 /// `type` is defined as `bsl::true_type` if `t_TYPE` is convertible to
112 /// `UniqueType` and `bsl::false_type` otherwise.
114};
115
116/// This `struct` template implements a meta-function to determine if the
117/// (template parameter) `t_TYPE` is convertible to any other type. This
118/// `struct` derives from `bsl::true_type` if `t_TYPE` is convertible to any
119/// type, and `bsl::false_type` otherwise.
120template <class t_TYPE>
122};
123
124} // close package namespace
125
126
127
128#endif
129
130// ----------------------------------------------------------------------------
131// Copyright 2013 Bloomberg Finance L.P.
132//
133// Licensed under the Apache License, Version 2.0 (the "License");
134// you may not use this file except in compliance with the License.
135// You may obtain a copy of the License at
136//
137// http://www.apache.org/licenses/LICENSE-2.0
138//
139// Unless required by applicable law or agreed to in writing, software
140// distributed under the License is distributed on an "AS IS" BASIS,
141// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
142// See the License for the specific language governing permissions and
143// limitations under the License.
144// ----------------------------- END-OF-FILE ----------------------------------
145
146/** @} */
147/** @} */
148/** @} */
Definition bslmf_isconvertibletoany.h:103
bsl::is_convertible< t_TYPE, UniqueType >::type type
Definition bslmf_isconvertibletoany.h:113
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlbb_blob.h:576
Definition bslmf_isconvertible.h:867
Definition bslmf_isconvertibletoany.h:121