~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to libs/boost-lib/boost/type_traits/is_convertible.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
Import upstream version 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
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)
5
5
//
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
14
14
 
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"
23
 
#endif
24
 
 
25
 
#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300)
26
 
#   include "boost/type_traits/is_void.hpp"
27
 
#endif
 
25
#include <boost/type_traits/is_abstract.hpp>
 
26
#endif
 
27
 
 
28
#if defined(__MWERKS__)
 
29
#include <boost/type_traits/is_function.hpp>
 
30
#include <boost/type_traits/remove_reference.hpp>
 
31
#endif
 
32
 
 
33
#endif // BOOST_IS_CONVERTIBLE
28
34
 
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>
31
37
 
32
38
namespace boost {
33
39
 
 
40
#ifndef BOOST_IS_CONVERTIBLE
 
41
 
34
42
// is one type convertable to another?
35
43
//
36
44
// there are multiple versions of the is_convertible
124
132
struct is_convertible_basic_impl
125
133
{
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);
129
137
};
130
138
 
186
194
        };
187
195
};
188
196
 
 
197
#elif defined(__MWERKS__)
 
198
// 
 
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.
 
203
//
 
204
 
 
205
template <typename From, typename To,bool FromIsFunctionRef>
 
206
struct is_convertible_basic_impl_aux;
 
207
 
 
208
struct any_conversion
 
209
{
 
210
    template <typename T> any_conversion(const volatile T&);
 
211
};
 
212
 
 
213
template <typename From, typename To>
 
214
struct is_convertible_basic_impl_aux<From,To,false /*FromIsFunctionRef*/>
 
215
{
 
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);
 
218
    static From _m_from;
 
219
 
 
220
    BOOST_STATIC_CONSTANT(bool, value =
 
221
        sizeof( _m_check(_m_from, 0) ) == sizeof(::boost::type_traits::yes_type)
 
222
        );
 
223
};
 
224
 
 
225
template <typename From, typename To>
 
226
struct is_convertible_basic_impl_aux<From,To,true /*FromIsFunctionRef*/>
 
227
{
 
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);
 
230
    static From _m_from;
 
231
    BOOST_STATIC_CONSTANT(bool, value =
 
232
        sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
 
233
        );
 
234
};
 
235
 
 
236
template <typename From, typename To>
 
237
struct is_convertible_basic_impl:
 
238
  is_convertible_basic_impl_aux<
 
239
    From,To,
 
240
    ::boost::is_function<typename ::boost::remove_reference<From>::type>::value
 
241
  >
 
242
{};
 
243
 
189
244
#else
190
245
 
191
246
//
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;
201
 
 
 
256
#ifdef BOOST_MSVC
 
257
#pragma warning(push)
 
258
#pragma warning(disable:4244)
 
259
#if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000)
 
260
#pragma warning(disable:6334)
 
261
#endif
 
262
#endif
202
263
    BOOST_STATIC_CONSTANT(bool, value =
203
264
        sizeof( _m_check(_m_from) ) == sizeof(::boost::type_traits::yes_type)
204
265
        );
 
266
#ifdef BOOST_MSVC
 
267
#pragma warning(pop)
 
268
#endif
205
269
};
206
270
 
207
271
#endif // is_convertible_impl
213
277
{
214
278
    typedef typename add_reference<From>::type ref_type;
215
279
    enum { value =
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
 
284
            >::value,
218
285
            ::boost::type_traits::ice_not<
219
 
                ::boost::is_array<To>::value
220
 
            >::value,
221
 
        >::value };
 
286
               ::boost::is_array<To>::value
 
287
            >::value
 
288
        >::value) };
222
289
};
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
 
300
            >::value,
231
301
            ::boost::type_traits::ice_not<
232
302
               ::boost::is_array<To>::value
233
303
            >::value
279
349
template <typename From, typename To>
280
350
struct is_convertible_impl_dispatch_base
281
351
{
282
 
#ifndef __HP_aCC
 
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,
332
402
 
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)
343
413
#endif
344
414
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
345
415
 
347
417
 
348
418
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,(::boost::detail::is_convertible_impl_dispatch<From,To>::value))
349
419
 
 
420
#else
 
421
 
 
422
BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_convertible,From,To,BOOST_IS_CONVERTIBLE(From,To))
 
423
 
 
424
#endif
 
425
 
350
426
} // namespace boost
351
427
 
352
 
#include "boost/type_traits/detail/bool_trait_undef.hpp"
 
428
#include <boost/type_traits/detail/bool_trait_undef.hpp>
353
429
 
354
430
#endif // BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED