Boost logo

Boost :

From: Trevor Perrin (tperrin_at_[hidden])
Date: 2001-07-08 19:19:08


Ah, sorry. I'd tried that but changed cause the compile errors were worse.
As you can tell I'm a little over my head here:) Anyways the below I think
is right, but still doesn't compile, so I'm inclined to think this is VC's
fault.

BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE
template <class T>
PyObject* to_python(boostold::shared_ptr<T> p)
{
    return
boost::python::python_extension_class_converters<T>::smart_ptr_to_python(p);
}

template <class T>
boostold::shared_ptr<T>& from_python(PyObject* p,
boost::python::type<boostold::shared_ptr<T>&>)
    { return
boost::python::python_extension_class_converters<T>::smart_ptr_reference(p,
boost::python::type<boostold::shared_ptr<T> >()); }

template <class T>
const boostold::shared_ptr<T>& from_python(PyObject* p,
boost::python::type<boostold::shared_ptr<T> >)
    { return
boost::python::python_extension_class_converters<T>::smart_ptr_value(p,
boost::python::type<boostold::shared_ptr<T> >()); }

template <class T>
const boostold::shared_ptr<T>& from_python(PyObject* p,
boost::python::type<const boostold::shared_ptr<T>&>)
    { return
boost::python::python_extension_class_converters<T>::smart_ptr_value(p,
boost::python::type<boostold::shared_ptr<T> >()); }

BOOST_PYTHON_END_CONVERSION_NAMESPACE

c:\testbp\testbp.cpp(29) : error C2995: 'from_python' : template function
has already been defined
        c:\testbp\testbp.cpp(24) : see declaration of 'from_python'
c:\boost\boost_1_22_0\boost\python\detail\extension_class.hpp(243) : error
C2556: 'class hello *__cdecl boost::python::from_python(struct _object
*,struct boost::python::type<class hello *>)' : overloaded function differs
only by return type from 'c
onst class boostold::shared_ptr<T> &__cdecl
boost::python::from_python(struct _object *,struct boost::python::type<class
boostold::shared_ptr<T> >)'
        c:\testbp\testbp.cpp(24) : see declaration of 'from_python'
        c:\boost\boost_1_22_0\boost\python\class_builder.hpp(20) : see
reference to class template instantiation
'boost::python::python_extension_class_converters<class hello,class
boost::python::detail::held_instance<class hello> >' being compiled
        c:\testbp\testbp.cpp(51) : see reference to class template
instantiation 'boost::python::class_builder<class hello,class
boost::python::detail::held_instance<class hello> >' being compiled
c:\boost\boost_1_22_0\boost\python\detail\extension_class.hpp(244) : error
C2059: syntax error : 'if'

Etc...

-----Original Message-----
From: David Abrahams [mailto:david.abrahams_at_[hidden]]
Sent: Sunday, July 08, 2001 5:10 PM
To: boost_at_[hidden]
Subject: Re: [boost] Python & smart pointers

Trevor:

----- Original Message -----
From: "Trevor Perrin" <tperrin_at_[hidden]>
> I included the variants;

No you did not. All the from_python functions must take a 2nd argument of
boost::python::type<U>, where U is the type being converted to, as the
examples I posted show. Yours take 2nd arguments U.

Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk