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 |
|
---|
20 | namespace boost { namespace python { namespace detail {
|
---|
21 |
|
---|
22 | typedef std::type_info const& typeinfo;
|
---|
23 |
|
---|
24 | template <class T>
|
---|
25 | static typeinfo typeid_nonref(T const volatile*) { return typeid(T); }
|
---|
26 |
|
---|
27 | template <class T>
|
---|
28 | inline typeinfo typeid_ref_1(T&(*)())
|
---|
29 | {
|
---|
30 | return detail::typeid_nonref((T*)0);
|
---|
31 | }
|
---|
32 |
|
---|
33 | // A non-reference
|
---|
34 | template <class T>
|
---|
35 | inline typeinfo typeid_ref(type<T>*, T&(*)(type<T>))
|
---|
36 | {
|
---|
37 | return detail::typeid_nonref((T*)0);
|
---|
38 | }
|
---|
39 |
|
---|
40 | // A reference
|
---|
41 | template <class T>
|
---|
42 | inline typeinfo typeid_ref(type<T>*, ...)
|
---|
43 | {
|
---|
44 | return detail::typeid_ref_1((T(*)())0);
|
---|
45 | }
|
---|
46 |
|
---|
47 | template< typename T > T&(* is_ref_tester1(type<T>) )(type<T>) { return 0; }
|
---|
48 | inline char BOOST_TT_DECL is_ref_tester1(...) { return 0; }
|
---|
49 |
|
---|
50 | template <class T>
|
---|
51 | inline 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 |
|
---|
58 | template <>
|
---|
59 | inline typeinfo msvc_typeid<void>(boost::type<void>*)
|
---|
60 | {
|
---|
61 | return typeid(void);
|
---|
62 | }
|
---|
63 |
|
---|
64 | # ifndef NDEBUG
|
---|
65 | inline 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
|
---|