[C++-sig] Re: pure virtual methods with pyste

Nicodemus nicodemus at globalite.com.br
Tue Aug 26 02:48:08 CEST 2003


David Abrahams wrote:

>OK, done; see <boost/python/pure_virtual.hpp>.  Perhaps you should
>change Pyste to use this facility.
>

I did, but I am getting this compiler error:

pure.cpp
d:/programming/libraries/boost-cvs/boost/boost/python/detail/nullary_function_ad
aptor.hpp(33): catastrophic error: expected a file name
  # include BOOST_PP_LOCAL_ITERATE()
            ^


Perhaps I am missing something? Here is the code:







// Includes 
====================================================================
#include <pure.h>
#include <boost/python/pure_virtual.hpp>
#include <boost/python.hpp>

// Using 
=======================================================================
using namespace boost::python;

// Declarations 
================================================================
namespace  {

struct A_Wrapper: A
{
    A_Wrapper(PyObject* self_, const A& p0):
        A(p0), self(self_) {}

    A_Wrapper(PyObject* self_):
        A(), self(self_) {}

    void foo() {
        call_method< void >(self, "foo");
    }

    PyObject* self;
};


}// namespace


// Module 
======================================================================
BOOST_PYTHON_MODULE(pure)
{
    class_< A, boost::noncopyable, A_Wrapper >("A", init<  >())
        .def("foo", pure_virtual(&A::foo), &A_Wrapper::default_foo)
    ;

}
 





More information about the Cplusplus-sig mailing list