Question about exposing template class to python using boost::python

Hi, I implemented a template<class T, int d> VECTOR; Now I can expose specialized class like VECTOR<int,2> to python, but I want to expose more specializations without copying a whole set. What shall I do? I found some early posts about this problem, but didn't figure out a solution. Is class_builder the one I should look for? Thanks in advance? Yong

At Tue, 22 Jun 2010 17:06:26 -0700, Yongning Zhu wrote:
Hi,
I implemented a template<class T, int d> VECTOR;
Now I can expose specialized class like VECTOR<int,2> to python, but I want to expose more specializations without copying a whole set. What shall I do?
Write a template that contains the code to expose one specialization, then use that over and over. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

On 6/23/2010 4:37 AM, David Abrahams wrote:
At Tue, 22 Jun 2010 17:06:26 -0700, Yongning Zhu wrote:
Hi,
I implemented a template<class T, int d> VECTOR;
Now I can expose specialized class like VECTOR<int,2> to python, but I want to expose more specializations without copying a whole set. What shall I do?
Write a template that contains the code to expose one specialization, then use that over and over.
Without being familiar with Boost.Python, might the "over and over" be "generateable" automatically with Boost.Preprocessor...? - Jeff

Thanks for everyone's reply. I am not quite sure about what this mean, nor boost.preprocessor. I wrote a template function for each class I want to templatize, and call that function for each specialized object class_<>, and it seems it is working. Thanks yong On Wed, Jun 23, 2010 at 4:37 AM, David Abrahams <dave@boostpro.com> wrote:
At Tue, 22 Jun 2010 17:06:26 -0700, Yongning Zhu wrote:
Hi,
I implemented a template<class T, int d> VECTOR;
Now I can expose specialized class like VECTOR<int,2> to python, but I want to expose more specializations without copying a whole set. What shall I do?
Write a template that contains the code to expose one specialization, then use that over and over.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
David Abrahams
-
Jeffrey Lee Hellrung, Jr.
-
Yongning Zhu