[C++-sig] wrapping a Singleton class

David Abrahams dave at boost-consulting.com
Sun Jun 12 18:08:07 CEST 2005


Faheem Mitha <faheem at email.unc.edu> writes:

> ********************************************************
> class lustate
> {
> public:
>   static lustate& instance(const vector<double>& lower, 
> 			   const vector<double>& upper)
>   {
>     static lustate lu(lower, upper);
>     return lu;
>   };
>   vector<double> l;
>   vector<double> u;
> private:
>   lustate(const vector<double>& _l, const vector<double>& _u): 
>     l(_l), u(_u) {};
> };
> ****************************************************************
>
> I tried
>
> BOOST_PYTHON_MODULE(mg)
> {
>   boost::python::class_<lustate>("lustate", boost::python::no_init)
>   // boost::python::class_<lustate>("lustate")

You're missing
      .def("instance", &lustate::instance)
right here.
>     .staticmethod("instance")
>     ;
> }

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list