2
2
// Copyright 2000 John Maddock (john@johnmaddock.co.uk)
3
3
// Copyright 2000 Jeremy Siek (jsiek@lsc.nd.edu)
4
// Copyright 1999, 2000 Jaakko J�rvi (jaakko.jarvi@cs.utu.fi)
4
// Copyright 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
6
6
// Use, modification and distribution are subject to the Boost Software License,
7
7
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12
12
#ifndef BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
13
13
#define BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
15
#include "boost/type_traits/detail/yes_no_type.hpp"
16
#include "boost/type_traits/config.hpp"
17
#include "boost/type_traits/is_array.hpp"
18
#include "boost/type_traits/add_reference.hpp"
19
#include "boost/type_traits/ice.hpp"
20
#include "boost/type_traits/is_arithmetic.hpp"
15
#include <boost/type_traits/intrinsics.hpp>
16
#ifndef BOOST_IS_CONVERTIBLE
17
#include <boost/type_traits/detail/yes_no_type.hpp>
18
#include <boost/type_traits/config.hpp>
19
#include <boost/type_traits/is_array.hpp>
20
#include <boost/type_traits/add_reference.hpp>
21
#include <boost/type_traits/ice.hpp>
22
#include <boost/type_traits/is_arithmetic.hpp>
23
#include <boost/type_traits/is_void.hpp>
21
24
#ifndef BOOST_NO_IS_ABSTRACT
22
#include "boost/type_traits/is_abstract.hpp"
25
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
26
# include "boost/type_traits/is_void.hpp"
25
#include <boost/type_traits/is_abstract.hpp>
28
#if defined(__MWERKS__)
29
#include <boost/type_traits/is_function.hpp>
30
#include <boost/type_traits/remove_reference.hpp>
33
#endif // BOOST_IS_CONVERTIBLE
29
35
// should be always the last #include directive
30
#include "boost/type_traits/detail/bool_trait_def.hpp"
36
#include <boost/type_traits/detail/bool_trait_def.hpp>
40
#ifndef BOOST_IS_CONVERTIBLE
34
42
// is one type convertable to another?
36
44
// there are multiple versions of the is_convertible
124
132
struct is_convertible_basic_impl
126
134
static From _m_from;
127
static bool const value = sizeof( detail::checker<To>::_m_check(_m_from, 0) )
135
static bool const value = sizeof( boost::detail::checker<To>::_m_check(_m_from, 0) )
128
136
== sizeof(::boost::type_traits::yes_type);
197
#elif defined(__MWERKS__)
199
// CW works with the technique implemented above for EDG, except when From
200
// is a function type (or a reference to such a type), in which case
201
// any_conversion won't be accepted as a valid conversion. We detect this
202
// exceptional situation and channel it through an alternative algorithm.
205
template <typename From, typename To,bool FromIsFunctionRef>
206
struct is_convertible_basic_impl_aux;
208
struct any_conversion
210
template <typename T> any_conversion(const volatile T&);
213
template <typename From, typename To>
214
struct is_convertible_basic_impl_aux<From,To,false /*FromIsFunctionRef*/>
216
static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...);
217
static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int);
220
BOOST_STATIC_CONSTANT(bool, value =
221
sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
225
template <typename From, typename To>
226
struct is_convertible_basic_impl_aux<From,To,true /*FromIsFunctionRef*/>
228
static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
229
static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
231
BOOST_STATIC_CONSTANT(bool, value =
232
sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
236
template <typename From, typename To>
237
struct is_convertible_basic_impl:
238
is_convertible_basic_impl_aux<
240
::boost::is_function<typename ::boost::remove_reference<From>::type>::value
198
253
static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
199
254
static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
200
255
static From _m_from;
257
#pragma warning(push)
258
#pragma warning(disable:4244)
259
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
260
#pragma warning(disable:6334)
202
263
BOOST_STATIC_CONSTANT(bool, value =
203
264
sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
207
271
#endif // is_convertible_impl
214
278
typedef typename add_reference<From>::type ref_type;
216
::boost::type_traits::ice_and<
217
::boost::detail::is_convertible_basic_impl<ref_type, To>::value,
280
(::boost::type_traits::ice_and<
281
::boost::type_traits::ice_or<
282
::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
283
::boost::is_void<To>::value
218
285
::boost::type_traits::ice_not<
219
::boost::is_array<To>::value
286
::boost::is_array<To>::value
223
290
#elif !defined(__BORLANDC__) || __BORLANDC__ > 0x551
224
291
template <typename From, typename To>
227
294
typedef typename add_reference<From>::type ref_type;
228
295
BOOST_STATIC_CONSTANT(bool, value =
229
296
(::boost::type_traits::ice_and<
230
::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
297
::boost::type_traits::ice_or<
298
::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
299
::boost::is_void<To>::value
231
301
::boost::type_traits::ice_not<
232
302
::boost::is_array<To>::value
279
349
template <typename From, typename To>
280
350
struct is_convertible_impl_dispatch_base
352
#if !BOOST_WORKAROUND(__HP_aCC, < 60700)
283
353
typedef is_convertible_impl_select<
284
354
::boost::is_arithmetic<From>::value,
285
355
::boost::is_arithmetic<To>::value,
333
403
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
334
404
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void,To,false)
335
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void,false)
405
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void,true)
336
406
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
337
407
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const,To,false)
338
408
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void volatile,To,false)
339
409
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const volatile,To,false)
340
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const,false)
341
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void volatile,false)
342
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const volatile,false)
410
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const,true)
411
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void volatile,true)
412
BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const volatile,true)
344
414
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
348
418
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,(::boost::detail::is_convertible_impl_dispatch<From,To>::value))
422
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,BOOST_IS_CONVERTIBLE(From,To))
350
426
} // namespace boost
352
#include "boost/type_traits/detail/bool_trait_undef.hpp"
428
#include <boost/type_traits/detail/bool_trait_undef.hpp>
354
430
#endif // BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED