1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/ptr_container/detail/is_convertible.hpp Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,416 @@
1.4 +
1.5 +// Copyright 2000 John Maddock (john@johnmaddock.co.uk)
1.6 +// Copyright 2000 Jeremy Siek (jsiek@lsc.nd.edu)
1.7 +// Copyright 1999, 2000 Jaakko J„rvi (jaakko.jarvi@cs.utu.fi)
1.8 +//
1.9 +// Use, modification and distribution are subject to the Boost Software License,
1.10 +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.11 +// http://www.boost.org/LICENSE_1_0.txt).
1.12 +//
1.13 +// See http://www.boost.org/libs/type_traits for most recent version including documentation.
1.14 +
1.15 +#ifndef BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
1.16 +#define BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
1.17 +
1.18 +#include <boost/type_traits/detail/yes_no_type.hpp>
1.19 +#include <boost/type_traits/config.hpp>
1.20 +#include <boost/type_traits/is_array.hpp>
1.21 +#include <boost/type_traits/add_reference.hpp>
1.22 +#include <boost/type_traits/ice.hpp>
1.23 +#include <boost/type_traits/is_arithmetic.hpp>
1.24 +#include <boost/type_traits/is_void.hpp>
1.25 +#ifndef BOOST_NO_IS_ABSTRACT
1.26 +#include <boost/type_traits/is_abstract.hpp>
1.27 +#endif
1.28 +
1.29 +#if defined(__MWERKS__)
1.30 +#include <boost/type_traits/is_function.hpp>
1.31 +#include <boost/type_traits/remove_reference.hpp>
1.32 +#endif
1.33 +
1.34 +// should be always the last #include directive
1.35 +#include <boost/type_traits/detail/bool_trait_def.hpp>
1.36 +
1.37 +namespace boost {
1.38 +
1.39 +// is one type convertable to another?
1.40 +//
1.41 +// there are multiple versions of the is_convertible
1.42 +// template, almost every compiler seems to require its
1.43 +// own version.
1.44 +//
1.45 +// Thanks to Andrei Alexandrescu for the original version of the
1.46 +// conversion detection technique!
1.47 +//
1.48 +
1.49 +namespace detail {
1.50 +
1.51 +// MS specific version:
1.52 +
1.53 +#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
1.54 +
1.55 +// This workaround is necessary to handle when From is void
1.56 +// which is normally taken care of by the partial specialization
1.57 +// of the is_convertible typename.
1.58 +using ::boost::type_traits::yes_type;
1.59 +using ::boost::type_traits::no_type;
1.60 +
1.61 +template< typename From >
1.62 +struct does_conversion_exist
1.63 +{
1.64 + template< typename To > struct result_
1.65 + {
1.66 + static no_type BOOST_TT_DECL _m_check(...);
1.67 + static yes_type BOOST_TT_DECL _m_check(To);
1.68 + static From _m_from;
1.69 + enum { value = sizeof( _m_check(_m_from) ) == sizeof(yes_type) };
1.70 + };
1.71 +};
1.72 +
1.73 +template<>
1.74 +struct does_conversion_exist<void>
1.75 +{
1.76 + template< typename To > struct result_
1.77 + {
1.78 + enum { value = ::boost::is_void<To>::value };
1.79 + };
1.80 +};
1.81 +
1.82 +template <typename From, typename To>
1.83 +struct is_convertible_basic_impl
1.84 + : does_conversion_exist<From>::template result_<To>
1.85 +{
1.86 +};
1.87 +
1.88 +#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x560)
1.89 +//
1.90 +// special version for Borland compilers
1.91 +// this version breaks when used for some
1.92 +// UDT conversions:
1.93 +//
1.94 +template <typename From, typename To>
1.95 +struct is_convertible_impl
1.96 +{
1.97 +#pragma option push -w-8074
1.98 + // This workaround for Borland breaks the EDG C++ frontend,
1.99 + // so we only use it for Borland.
1.100 + template <typename T> struct checker
1.101 + {
1.102 + static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
1.103 + static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(T);
1.104 + };
1.105 +
1.106 + static From _m_from;
1.107 + static bool const value = sizeof( checker<To>::_m_check(_m_from) )
1.108 + == sizeof(::boost::type_traits::yes_type);
1.109 +#pragma option pop
1.110 +};
1.111 +
1.112 +#elif defined(__GNUC__) || defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
1.113 +// special version for gcc compiler + recent Borland versions
1.114 +// note that this does not pass UDT's through (...)
1.115 +
1.116 +struct any_conversion
1.117 +{
1.118 + template <typename T> any_conversion(const volatile T&);
1.119 + template <typename T> any_conversion(T&);
1.120 +};
1.121 +
1.122 +template <typename T> struct checker
1.123 +{
1.124 + static boost::type_traits::no_type _m_check(any_conversion ...);
1.125 + static boost::type_traits::yes_type _m_check(T, int);
1.126 +};
1.127 +
1.128 +template <typename From, typename To>
1.129 +struct is_convertible_basic_impl
1.130 +{
1.131 + static From _m_from;
1.132 + static bool const value = sizeof( detail::checker<To>::_m_check(_m_from, 0) )
1.133 + == sizeof(::boost::type_traits::yes_type);
1.134 +};
1.135 +
1.136 +#elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
1.137 + || defined(__IBMCPP__) || defined(__HP_aCC)
1.138 +//
1.139 +// This is *almost* an ideal world implementation as it doesn't rely
1.140 +// on undefined behaviour by passing UDT's through (...).
1.141 +// Unfortunately it doesn't quite pass all the tests for most compilers (sigh...)
1.142 +// Enable this for your compiler if is_convertible_test.cpp will compile it...
1.143 +//
1.144 +// Note we do not enable this for VC7.1, because even though it passes all the
1.145 +// type_traits tests it is known to cause problems when instantiation occurs
1.146 +// deep within the instantiation tree :-(
1.147 +//
1.148 +struct any_conversion
1.149 +{
1.150 + template <typename T> any_conversion(const volatile T&);
1.151 + // we need this constructor to catch references to functions
1.152 + // (which can not be cv-qualified):
1.153 + template <typename T> any_conversion(T&);
1.154 +};
1.155 +
1.156 +template <typename From, typename To>
1.157 +struct is_convertible_basic_impl
1.158 +{
1.159 + static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...);
1.160 + static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int);
1.161 + static From _m_from;
1.162 +
1.163 + BOOST_STATIC_CONSTANT(bool, value =
1.164 + sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
1.165 + );
1.166 +};
1.167 +
1.168 +#elif defined(__DMC__)
1.169 +
1.170 +struct any_conversion
1.171 +{
1.172 + template <typename T> any_conversion(const volatile T&);
1.173 + // we need this constructor to catch references to functions
1.174 + // (which can not be cv-qualified):
1.175 + template <typename T> any_conversion(T&);
1.176 +};
1.177 +
1.178 +template <typename From, typename To>
1.179 +struct is_convertible_basic_impl
1.180 +{
1.181 + // Using '...' doesn't always work on Digital Mars. This version seems to.
1.182 + template <class T>
1.183 + static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion, float, T);
1.184 + static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int, int);
1.185 + static From _m_from;
1.186 +
1.187 + // Static constants sometime cause the conversion of _m_from to To to be
1.188 + // called. This doesn't happen with an enum.
1.189 + enum { value =
1.190 + sizeof( _m_check(_m_from, 0, 0) ) == sizeof(::boost::type_traits::yes_type)
1.191 + };
1.192 +};
1.193 +
1.194 +#elif defined(__MWERKS__)
1.195 +//
1.196 +// CW works with the technique implemented above for EDG, except when From
1.197 +// is a function type (or a reference to such a type), in which case
1.198 +// any_conversion won't be accepted as a valid conversion. We detect this
1.199 +// exceptional situation and channel it through an alternative algorithm.
1.200 +//
1.201 +
1.202 +template <typename From, typename To,bool FromIsFunctionRef>
1.203 +struct is_convertible_basic_impl_aux;
1.204 +
1.205 +struct any_conversion
1.206 +{
1.207 + template <typename T> any_conversion(const volatile T&);
1.208 +};
1.209 +
1.210 +template <typename From, typename To>
1.211 +struct is_convertible_basic_impl_aux<From,To,false /*FromIsFunctionRef*/>
1.212 +{
1.213 + static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(any_conversion ...);
1.214 + static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To, int);
1.215 + static From _m_from;
1.216 +
1.217 + BOOST_STATIC_CONSTANT(bool, value =
1.218 + sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
1.219 + );
1.220 +};
1.221 +
1.222 +template <typename From, typename To>
1.223 +struct is_convertible_basic_impl_aux<From,To,true /*FromIsFunctionRef*/>
1.224 +{
1.225 + static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
1.226 + static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
1.227 + static From _m_from;
1.228 + BOOST_STATIC_CONSTANT(bool, value =
1.229 + sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
1.230 + );
1.231 +};
1.232 +
1.233 +template <typename From, typename To>
1.234 +struct is_convertible_basic_impl:
1.235 + is_convertible_basic_impl_aux<
1.236 + From,To,
1.237 + ::boost::is_function<typename ::boost::remove_reference<From>::type>::value
1.238 + >
1.239 +{};
1.240 +
1.241 +#else
1.242 +
1.243 +//
1.244 +// This version seems to work pretty well for a wide spectrum of compilers,
1.245 +// however it does rely on undefined behaviour by passing UDT's through (...).
1.246 +//
1.247 +template <typename From, typename To>
1.248 +struct is_convertible_basic_impl
1.249 +{
1.250 + static ::boost::type_traits::no_type BOOST_TT_DECL _m_check(...);
1.251 + static ::boost::type_traits::yes_type BOOST_TT_DECL _m_check(To);
1.252 + static From _m_from;
1.253 +#ifdef BOOST_MSVC
1.254 +#pragma warning(push)
1.255 +#pragma warning(disable:4244)
1.256 +#endif
1.257 + BOOST_STATIC_CONSTANT(bool, value =
1.258 + sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
1.259 + );
1.260 +#ifdef BOOST_MSVC
1.261 +#pragma warning(pop)
1.262 +#endif
1.263 +};
1.264 +
1.265 +#endif // is_convertible_impl
1.266 +
1.267 +#if defined(__DMC__)
1.268 +// As before, a static constant sometimes causes errors on Digital Mars.
1.269 +template <typename From, typename To>
1.270 +struct is_convertible_impl
1.271 +{
1.272 + typedef typename add_reference<From>::type ref_type;
1.273 + enum { value =
1.274 + (::boost::type_traits::ice_and<
1.275 + ::boost::type_traits::ice_or<
1.276 + ::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
1.277 + ::boost::is_void<To>::value
1.278 + >::value,
1.279 + ::boost::type_traits::ice_not<
1.280 + ::boost::is_array<To>::value
1.281 + >::value
1.282 + >::value) };
1.283 +};
1.284 +#elif !defined(__BORLANDC__) || __BORLANDC__ > 0x551
1.285 +template <typename From, typename To>
1.286 +struct is_convertible_impl
1.287 +{
1.288 + typedef typename add_reference<From>::type ref_type;
1.289 + BOOST_STATIC_CONSTANT(bool, value =
1.290 + (::boost::type_traits::ice_and<
1.291 + ::boost::type_traits::ice_or<
1.292 + ::boost::detail::is_convertible_basic_impl<ref_type,To>::value,
1.293 + ::boost::is_void<To>::value
1.294 + >::value,
1.295 + ::boost::type_traits::ice_not<
1.296 + ::boost::is_array<To>::value
1.297 + >::value
1.298 + >::value)
1.299 + );
1.300 +};
1.301 +#endif
1.302 +
1.303 +template <bool trivial1, bool trivial2, bool abstract_target>
1.304 +struct is_convertible_impl_select
1.305 +{
1.306 + template <class From, class To>
1.307 + struct rebind
1.308 + {
1.309 + typedef is_convertible_impl<From, To> type;
1.310 + };
1.311 +};
1.312 +
1.313 +template <>
1.314 +struct is_convertible_impl_select<true, true, false>
1.315 +{
1.316 + template <class From, class To>
1.317 + struct rebind
1.318 + {
1.319 + typedef true_type type;
1.320 + };
1.321 +};
1.322 +
1.323 +template <>
1.324 +struct is_convertible_impl_select<false, false, true>
1.325 +{
1.326 + template <class From, class To>
1.327 + struct rebind
1.328 + {
1.329 + typedef false_type type;
1.330 + };
1.331 +};
1.332 +
1.333 +template <>
1.334 +struct is_convertible_impl_select<true, false, true>
1.335 +{
1.336 + template <class From, class To>
1.337 + struct rebind
1.338 + {
1.339 + typedef false_type type;
1.340 + };
1.341 +};
1.342 +
1.343 +template <typename From, typename To>
1.344 +struct is_convertible_impl_dispatch_base
1.345 +{
1.346 +#if !BOOST_WORKAROUND(__HP_aCC, < 60700)
1.347 + typedef is_convertible_impl_select<
1.348 + ::boost::is_arithmetic<From>::value,
1.349 + ::boost::is_arithmetic<To>::value,
1.350 +#ifndef BOOST_NO_IS_ABSTRACT
1.351 + ::boost::is_abstract<To>::value
1.352 +#else
1.353 + false
1.354 +#endif
1.355 + > selector;
1.356 +#else
1.357 + typedef is_convertible_impl_select<false, false, false> selector;
1.358 +#endif
1.359 + typedef typename selector::template rebind<From, To> isc_binder;
1.360 + typedef typename isc_binder::type type;
1.361 +};
1.362 +
1.363 +template <typename From, typename To>
1.364 +struct is_convertible_impl_dispatch
1.365 + : public is_convertible_impl_dispatch_base<From, To>::type
1.366 +{};
1.367 +
1.368 +//
1.369 +// Now add the full and partial specialisations
1.370 +// for void types, these are common to all the
1.371 +// implementation above:
1.372 +//
1.373 +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
1.374 +# define TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1,spec2,value) \
1.375 + BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2,value) \
1.376 + BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2 const,value) \
1.377 + BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2 volatile,value) \
1.378 + BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(trait,spec1,spec2 const volatile,value) \
1.379 + /**/
1.380 +
1.381 +# define TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2(trait,spec1,spec2,value) \
1.382 + TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1,spec2,value) \
1.383 + TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1 const,spec2,value) \
1.384 + TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1 volatile,spec2,value) \
1.385 + TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1(trait,spec1 const volatile,spec2,value) \
1.386 + /**/
1.387 +
1.388 + TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2(is_convertible,void,void,true)
1.389 +
1.390 +# undef TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2
1.391 +# undef TT_AUX_BOOL_CV_VOID_TRAIT_SPEC2_PART1
1.392 +
1.393 +#else
1.394 + BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC2(is_convertible,void,void,true)
1.395 +#endif // BOOST_NO_CV_VOID_SPECIALIZATIONS
1.396 +
1.397 +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.398 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void,To,false)
1.399 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void,true)
1.400 +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
1.401 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const,To,false)
1.402 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void volatile,To,false)
1.403 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename To,is_convertible,void const volatile,To,false)
1.404 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const,true)
1.405 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void volatile,true)
1.406 +BOOST_TT_AUX_BOOL_TRAIT_IMPL_PARTIAL_SPEC2_1(typename From,is_convertible,From,void const volatile,true)
1.407 +#endif
1.408 +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
1.409 +
1.410 +} // namespace detail
1.411 +
1.412 +BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,(::boost::detail::is_convertible_impl_dispatch<From,To>::value))
1.413 +
1.414 +} // namespace boost
1.415 +
1.416 +#include <boost/type_traits/detail/bool_trait_undef.hpp>
1.417 +
1.418 +#endif // BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
1.419 +