[857] | 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 POINTER_TYPE_ID_DWA2002222_HPP
|
---|
| 6 | # define POINTER_TYPE_ID_DWA2002222_HPP
|
---|
| 7 |
|
---|
| 8 | # include <boost/python/type_id.hpp>
|
---|
| 9 | # include <boost/type_traits/composite_traits.hpp>
|
---|
| 10 |
|
---|
| 11 | namespace boost { namespace python { namespace converter {
|
---|
| 12 |
|
---|
| 13 | namespace detail
|
---|
| 14 | {
|
---|
| 15 | template <bool is_ref = false>
|
---|
| 16 | struct pointer_typeid_select
|
---|
| 17 | {
|
---|
| 18 | template <class T>
|
---|
| 19 | static inline type_info execute(T*(*)() = 0)
|
---|
| 20 | {
|
---|
| 21 | return type_id<T>();
|
---|
| 22 | }
|
---|
| 23 | };
|
---|
| 24 |
|
---|
| 25 | template <>
|
---|
| 26 | struct pointer_typeid_select<true>
|
---|
| 27 | {
|
---|
| 28 | template <class T>
|
---|
| 29 | static inline type_info execute(T* const volatile&(*)() = 0)
|
---|
| 30 | {
|
---|
| 31 | return type_id<T>();
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | template <class T>
|
---|
| 35 | static inline type_info execute(T*volatile&(*)() = 0)
|
---|
| 36 | {
|
---|
| 37 | return type_id<T>();
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | template <class T>
|
---|
| 41 | static inline type_info execute(T*const&(*)() = 0)
|
---|
| 42 | {
|
---|
| 43 | return type_id<T>();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | template <class T>
|
---|
| 47 | static inline type_info execute(T*&(*)() = 0)
|
---|
| 48 | {
|
---|
| 49 | return type_id<T>();
|
---|
| 50 | }
|
---|
| 51 | };
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | // Usage: pointer_type_id<T>()
|
---|
| 55 | //
|
---|
| 56 | // Returns a type_info associated with the type pointed
|
---|
| 57 | // to by T, which may be a pointer or a reference to a pointer.
|
---|
| 58 | template <class T>
|
---|
| 59 | type_info pointer_type_id(T(*)() = 0)
|
---|
| 60 | {
|
---|
| 61 | return detail::pointer_typeid_select<
|
---|
| 62 | is_reference<T>::value
|
---|
| 63 | >::execute((T(*)())0);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | }}} // namespace boost::python::converter
|
---|
| 67 |
|
---|
| 68 | #endif // POINTER_TYPE_ID_DWA2002222_HPP
|
---|