From da273519fd32fa0829751a449605064bef99b41c Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Thu, 24 Oct 2002 21:12:37 +0000 Subject: [PATCH] added non_copyable to second version of class_

In Python, let us try to instantiate our Base class:

-
+
+
     >>> base = Base()
-    AttributeError: ...
-
+ RuntimeError: This class cannot be instantiated from Python
+

Why is it an error? Base is an abstract class. As such it is advisable to define the Python wrapper with no_init as we have done above. Doing @@ -167,11 +168,12 @@ And instead is implemented to return 0, as shown above.

then, our Boost.Python wrapper:

-
-    class_<Base, BaseWrap>("Base")
+
+
    class_<Base, BaseWrap, boost::non_copyable>("Base")
         .def("f", &BaseWrap::default_f)
         ;
-
+
+

Note that we are allowing Base objects to be instantiated this time, unlike before where we specifically defined the class_<Base> with