2016-03-23 23 views
1

aşağıdaki formu imzasını olan Boost.Python ile sınıf Cube sarmak için çalışıyorum:Boost.Python veya std `için std :: tuple`` için piton tuple dönüştürme :: pair`

void insert(const std::pair< int, int>& x){ ... do something .. } 
sadece bu yöntemi tamamlamayı eğer

şöyle:

.def("append", &Cube::insert, with_custodian_and_ward<1,2>()) 

alıyorum piton aşağıdaki hata:

ArgumentError: Python argument types in 
    cube.append(cube, list) 
did not match C++ signature: 
    append(Cube {lvalue}, std::__1::pair<unsigned long, unsigned long>) 

yazdığım zaman:

cube.append((1,2)) 

Python türünü C++ türüne doğru şekilde nasıl dönüştüreceğimi bilmiyorum. Uygun bir örnek de bulamıyorum.

.def("append", FunctionPointer([] (Cube& self, const bp::object& obj) 
    { 
    self.insert(std::make_pair(bp::extract<int>(obj[0]),bp::extract<int>(obj[1]))); 
    })) 
:

cevap

0

Ben kolay yolu açıkça C++ std :: çifti içine piton nesneyi dönüştürmek olacağını düşünüyorum
İlgili konular