source: NonGTP/Boost/boost/python/detail/msvc_typeinfo.hpp @ 857

Revision 857, 1.9 KB checked in by igarcia, 18 years ago (diff)
Line 
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef MSVC_TYPEINFO_DWA200222_HPP
6# define MSVC_TYPEINFO_DWA200222_HPP
7
8#include <typeinfo>
9#include <boost/type.hpp>
10#include <boost/type_traits/config.hpp>
11
12//
13// Fix for MSVC's broken typeid() implementation which doesn't strip
14// decoration. This fix doesn't handle cv-qualified array types. It
15// could probably be done, but I haven't figured it out yet.
16//
17
18# if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(BOOST_INTEL_CXX_VERSION) && BOOST_INTEL_CXX_VERSION <= 700
19
20namespace boost { namespace python { namespace detail {
21
22typedef std::type_info const& typeinfo;
23
24template <class T>
25static typeinfo typeid_nonref(T const volatile*) { return typeid(T); }
26
27template <class T>
28inline typeinfo typeid_ref_1(T&(*)())
29{
30    return detail::typeid_nonref((T*)0);
31}
32
33// A non-reference
34template <class T>
35inline typeinfo typeid_ref(type<T>*, T&(*)(type<T>))
36{
37    return detail::typeid_nonref((T*)0);
38}
39
40// A reference
41template <class T>
42inline typeinfo typeid_ref(type<T>*, ...)
43{
44    return detail::typeid_ref_1((T(*)())0);
45}
46
47template< typename T > T&(* is_ref_tester1(type<T>) )(type<T>) { return 0; }
48inline char BOOST_TT_DECL is_ref_tester1(...) { return 0; }
49
50template <class T>
51inline typeinfo msvc_typeid(boost::type<T>*)
52{
53    return detail::typeid_ref(
54        (boost::type<T>*)0, detail::is_ref_tester1(type<T>())
55        );
56}
57
58template <>
59inline typeinfo msvc_typeid<void>(boost::type<void>*)
60{
61    return typeid(void);
62}
63
64#  ifndef NDEBUG
65inline typeinfo assert_array_typeid_compiles()
66{
67    return msvc_typeid((boost::type<char const[3]>*)0)
68        , msvc_typeid((boost::type<char[3]>*)0);
69}
70#  endif
71
72}}} // namespace boost::python::detail
73
74# endif // BOOST_MSVC
75#endif // MSVC_TYPEINFO_DWA200222_HPP
Note: See TracBrowser for help on using the repository browser.