[C++-sig] call policies

David Abrahams dave at boost-consulting.com
Fri Oct 18 18:19:47 CEST 2002


Stefan Seefeld <seefeld at sympatico.ca> writes:

Stefan,

I think this is my fault. As you probably know, std::auto_ptr<>'s copy
constructor is weird: it takes a non-const RHS. I think I must've
failed to account for that. I'll look into providing a patch for this
case today.

Sorry,
Dave

> David Abrahams wrote:
> 
> >    Bar* BarFactory(std::auto_ptr<Foo> foo);
> >    class_<Foo, std::auto_ptr<Foo> >("Foo")
> >         ...
> >         ;
> 
> I'm trying to do what you suggest, with some additional parameters:
> 
> ----
> 
> #include <boost/python/module.hpp>
> #include <boost/python/class.hpp>
> #include <boost/python/def.hpp>
> 
> #include <memory>
> 
> namespace python = boost::python;
> 
> namespace
> {
> 
> class Bar {};
> 
> }
> 
> BOOST_PYTHON_MODULE(pfe)
> {
>     python::class_<Bar,
>                    std::auto_ptr<Bar>,
>                    boost::noncopyable> bar("Bar", python::no_init);
> 
> }
> 
> ----
> 
> I copied that over 'getting_started2.cc and run
> bjam "-sBUILD=<architecture>mips4" (with TOOLS=mipspro).
> 
> This results in the error message
> 
> cc-1306 CC: ERROR File =
> /homes/Developer/sseefel/boost/boost/python/object/make_instance.hpp,
> Line = 60
>    Class "std::auto_ptr<<unnamed>::Bar>" has no copy constructor to
> copy a const
>            object.
> 
>            return new ((void*)&result->storage) Holder(x);
> 
> ...
> 
> what is wrong ? I guess it's either boost:noncopyable or python::no_init
> though I don't see why that should be wrong.
> 
> Thanks,
> 		Stefan
> 
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 

-- 
                    David Abrahams
dave at boost-consulting.com * http://www.boost-consulting.com

Building C/C++ Extensions for Python: Dec 9-11, Austin, TX
http://www.enthought.com/training/building_extensions.html





More information about the Cplusplus-sig mailing list