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