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 IMPLICIT_DWA2002326_HPP sl@0: # define IMPLICIT_DWA2002326_HPP sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: # include sl@0: sl@0: namespace boost { namespace python { namespace converter { sl@0: sl@0: template sl@0: struct implicit sl@0: { sl@0: static void* convertible(PyObject* obj) sl@0: { sl@0: // Find a converter which can produce a Source instance from sl@0: // obj. The user has told us that Source can be converted to sl@0: // Target, and instantiating construct() below, ensures that sl@0: // at compile-time. sl@0: return implicit_rvalue_convertible_from_python(obj, registered::converters) sl@0: ? obj : 0; sl@0: } sl@0: sl@0: static void construct(PyObject* obj, rvalue_from_python_stage1_data* data) sl@0: { sl@0: void* storage = ((rvalue_from_python_storage*)data)->storage.bytes; sl@0: sl@0: arg_from_python get_source(obj); sl@0: bool convertible = get_source.convertible(); sl@0: BOOST_ASSERT(convertible); sl@0: sl@0: new (storage) Target(get_source()); sl@0: sl@0: // record successful construction sl@0: data->convertible = storage; sl@0: } sl@0: }; sl@0: sl@0: }}} // namespace boost::python::converter sl@0: sl@0: #endif // IMPLICIT_DWA2002326_HPP