オブジェクトから 2 番目の要素を削除しようとしていboost::python::tuple
ます。2 番目の要素を削除したいタプルは、Python 関数呼び出しに渡される引数のリストです。
要素を削除するには、次のようにします。
BPY::object CallMethod(BPY::tuple args, BPY::dict kwargs)
{
...
// args is my original tuple from which I want to remove the second element
boost::python::api::object_slice firstSlice = args.slice(0, 1);
boost::python::tuple newArgs = boost::python::extract<boost::python::tuple>(firstSlice);
if(boost::python::len(args) > 2)
{
boost::python::api::object_slice secondSlice = args.slice(2, boost::python::len(args));
boost::python::tuple secondSliceArgs = boost::python::extract<boost::python::tuple>(secondSlice);
newArgs = boost::python::make_tuple(newArgs, secondSliceArgs);
}
args = newArgs;
...
}
boost::python::tuple
問題は要素を追加しないことだと思いますが、最初と2番目のスライスを要素として新しいタプルを作成しました。
どうすればこれを解決できますか?