[C++-sig] How to use functionality of list.

vishal bayskar vishal.bayskar at nechclst.in
Wed May 5 12:19:22 CEST 2010


Actually I am able create wrapper code for list . All the functions of list
are exposed.
But when I try to compile it (try to create shared library) it showing below
error

-----------
testModule.cpp:11: error: _Alloc was not declared in this scope
testModule.cpp:18: error: _Tp was not declared in this scope
testModule.cpp:18: error: _Alloc was not declared in this scope
testModule.cpp: In function void init_module_testModule():
testModule.cpp:110: error: _Alloc was not declared in this scope
testModule.cpp:113: error: _Tp was not declared in this scope
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/list.tcc:
In member function âvoid std::list<_Tp, _Alloc>::merge(std::list<_Tp,
_Alloc>&) [with _Tp = A, _Alloc = std::allocator ]â:
testModule.cpp:368:   instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/list.tcc:222:
error: no match for âoperator<â in
â__first2.std::_List_iterator<_Tp>::operator* [with _Tp = A]() <
__first1.std::_List_iterator<_Tp>::operator* [with _Tp = A]()â
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/list.tcc:
In member function âvoid std::list<_Tp, _Alloc>::remove(const _Tp&) [with
_Tp = A, _Alloc = std::allocator ]â:
-----------

I think if I can somewhere declare _Alloc and _Tp I will be able to use it
(list) correctly.

Please let me know the possible solution
Below are the code (and one file is attahced) that is used.

cpp code : listP.cpp
===============
#include<iostream>
#include<list>
class A
{
public:
        A(int num):num(num)
        {
        }
private:
        int num;
};
class Alist :
        public std::list 
{
public:
static void a()
{
        std::cout << "check" << std::endl;
}


};

Alist getDummyAlist()
{
        Alist aList;
        A a1(5);
        A a2(6);
        aList.push_back(a1);
        aList.push_back(a2);

        return  aList;
};


python file for generating wrapper code : afile.py
====================================
import os
from pyplusplus import module_builder
from pyplusplus.module_builder import call_policies
from pyplusplus import code_creators

mb=module_builder.module_builder_t(["./listP.cpp"],
)

classA =  mb.class_('list<A, std::allocator  >')
classA.include()

for className in mb.classes():
       print "className : %s"%className
http://old.nabble.com/file/p28459066/testModule.cpp testModule.cpp 

mb.build_code_creator( module_name = 'testModule')

mb.write_module('./testModule.cpp')


Generated wrapper code : testModule.cpp
===============================
file testModule.cpp is uploaded (attached) on this page only.

-- 
View this message in context: http://old.nabble.com/How-to-use-functionality-of-list.-tp28459066p28459066.html
Sent from the Python - c++-sig mailing list archive at Nabble.com.



More information about the Cplusplus-sig mailing list