]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
11 | // | |
12 | // Fix for icc's broken typeid() implementation which doesn't strip | |
13 | // decoration. This fix doesn't handle cv-qualified array types. It | |
14 | // could probably be done, but I haven't figured it out yet. | |
15 | // | |
16 | ||
17 | // Note: This file is badly named. It initially was MSVC specific, but was | |
18 | // extended to cover intel too. Now the old version of MSVC is no longer | |
19 | // supported, but the intel version is still supported. | |
20 | ||
21 | # if defined(BOOST_INTEL_CXX_VERSION) && BOOST_INTEL_CXX_VERSION <= 700 | |
22 | ||
23 | namespace boost { namespace python { namespace detail { | |
24 | ||
25 | typedef std::type_info const& typeinfo; | |
26 | ||
27 | template <class T> | |
28 | static typeinfo typeid_nonref(T const volatile*) { return typeid(T); } | |
29 | ||
30 | template <class T> | |
31 | inline typeinfo typeid_ref_1(T&(*)()) | |
32 | { | |
33 | return detail::typeid_nonref((T*)0); | |
34 | } | |
35 | ||
36 | // A non-reference | |
37 | template <class T> | |
38 | inline typeinfo typeid_ref(type<T>*, T&(*)(type<T>)) | |
39 | { | |
40 | return detail::typeid_nonref((T*)0); | |
41 | } | |
42 | ||
43 | // A reference | |
44 | template <class T> | |
45 | inline typeinfo typeid_ref(type<T>*, ...) | |
46 | { | |
47 | return detail::typeid_ref_1((T(*)())0); | |
48 | } | |
49 | ||
50 | #if defined(BOOST_MSVC) || (defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)) | |
51 | # define BOOST_PYTT_DECL __cdecl | |
52 | #else | |
53 | # define BOOST_PYTT_DECL /**/ | |
54 | #endif | |
55 | ||
56 | template< typename T > T&(* is_ref_tester1(type<T>) )(type<T>) { return 0; } | |
57 | inline char BOOST_PYTT_DECL is_ref_tester1(...) { return 0; } | |
58 | ||
59 | template <class T> | |
60 | inline typeinfo msvc_typeid(boost::type<T>*) | |
61 | { | |
62 | return detail::typeid_ref( | |
63 | (boost::type<T>*)0, detail::is_ref_tester1(type<T>()) | |
64 | ); | |
65 | } | |
66 | ||
67 | template <> | |
68 | inline typeinfo msvc_typeid<void>(boost::type<void>*) | |
69 | { | |
70 | return typeid(void); | |
71 | } | |
72 | ||
73 | # ifndef NDEBUG | |
74 | inline typeinfo assert_array_typeid_compiles() | |
75 | { | |
76 | return msvc_typeid((boost::type<char const[3]>*)0) | |
77 | , msvc_typeid((boost::type<char[3]>*)0); | |
78 | } | |
79 | # endif | |
80 | ||
81 | }}} // namespace boost::python::detail | |
82 | ||
83 | # endif // BOOST_INTEL_CXX_VERSION | |
84 | #endif // MSVC_TYPEINFO_DWA200222_HPP |