Boost logo

Boost :

From: Neal D. Becker (ndbecker2_at_[hidden])
Date: 2004-10-19 13:43:15


You mean this?
,----[ /disk1/nbecker/stuff/A.hpp ]
| // {{{ struct A
|
| template<class i_type>
| struct A {
| i_type i;
| A() { i = 1; }
| static const A instance;
| };
|
| // }}}
|
| template<class i_type>
| extern const A<i_type> A<i_type>::instance = A();
|
| template<>
| extern const A<int> A<int>::instance = A<int>();
`----
,----[ /disk1/nbecker/stuff/A.cc ]
| #include <boost/python/module.hpp>
| #include <boost/python/def.hpp>
| #include <boost/python/class.hpp>
| #include <boost/python/init.hpp>
| #include <boost/python/reference_existing_object.hpp>
| #include "A.hpp"
|
| namespace python = boost::python;
|
| int get() { return int(&A<int>::instance); }
|
| BOOST_PYTHON_MODULE(A)
| {
| python::def ("get", &get);
| }
`----
,----[ /disk1/nbecker/stuff/B.cc ]
| #include <boost/python/module.hpp>
| #include <boost/python/def.hpp>
| #include <boost/python/class.hpp>
| #include <boost/python/init.hpp>
| #include <boost/python/reference_existing_object.hpp>
| #include "A.hpp"
|
| namespace python = boost::python;
|
| int get() { return int(&A<int>::instance); }
|
| BOOST_PYTHON_MODULE(B)
| {
| python::def ("get", &get);
| }
`----
python
Python 2.3.4 (#1, Aug 31 2004, 11:13:54)
[GCC 3.4.1 20040815 (Red Hat 3.4.1-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import dl
>>> sys.setdlopenflags (dl.RTLD_GLOBAL|dl.RTLD_NOW)
>>> import A
>>> import B
>>> A.get()
-155365500
>>> B.get()
-155365500


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