sl@0: // Copyright David Abrahams 2002. sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: #ifndef REGISTERED_DWA2002710_HPP sl@0: # define REGISTERED_DWA2002710_HPP sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: namespace boost { sl@0: sl@0: // You'll see shared_ptr mentioned in this header because we need to sl@0: // note which types are shared_ptrs in their registrations, to sl@0: // implement special shared_ptr handling for rvalue conversions. sl@0: template class shared_ptr; sl@0: sl@0: namespace python { namespace converter { sl@0: sl@0: struct registration; sl@0: sl@0: namespace detail sl@0: { sl@0: template sl@0: struct registered_base sl@0: { sl@0: static registration const& converters; sl@0: }; sl@0: } sl@0: sl@0: template sl@0: struct registered sl@0: : detail::registered_base< sl@0: typename add_reference< sl@0: typename add_cv::type sl@0: >::type sl@0: > sl@0: { sl@0: }; sl@0: sl@0: # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ sl@0: && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) sl@0: // collapses a few more types to the same static instance. MSVC7.1 sl@0: // fails to strip cv-qualification from array types in typeid. For sl@0: // some reason we can't use this collapse there or array converters sl@0: // will not be found. sl@0: template sl@0: struct registered sl@0: : registered {}; sl@0: # endif sl@0: sl@0: // sl@0: // implementations sl@0: // sl@0: namespace detail sl@0: { sl@0: inline void sl@0: register_shared_ptr0(...) sl@0: { sl@0: } sl@0: sl@0: template sl@0: inline void sl@0: register_shared_ptr0(shared_ptr*) sl@0: { sl@0: registry::lookup_shared_ptr(type_id >()); sl@0: } sl@0: sl@0: template sl@0: inline void sl@0: register_shared_ptr1(T const volatile*) sl@0: { sl@0: detail::register_shared_ptr0((T*)0); sl@0: } sl@0: sl@0: template sl@0: inline registration const& sl@0: registry_lookup2(T&(*)()) sl@0: { sl@0: detail::register_shared_ptr1((T*)0); sl@0: return registry::lookup(type_id()); sl@0: } sl@0: sl@0: template sl@0: inline registration const& sl@0: registry_lookup1(type) sl@0: { sl@0: return registry_lookup2((T(*)())0); sl@0: } sl@0: sl@0: inline registration const& sl@0: registry_lookup1(type) sl@0: { sl@0: detail::register_shared_ptr1((void*)0); sl@0: return registry::lookup(type_id()); sl@0: } sl@0: sl@0: template sl@0: registration const& registered_base::converters = detail::registry_lookup1(type()); sl@0: sl@0: } sl@0: sl@0: }}} // namespace boost::python::converter sl@0: sl@0: #endif // REGISTERED_DWA2002710_HPP