小编Nib*_*ose的帖子

用模板类提升python

我创建了一个环形缓冲区,我想使用boost将该类导入Python.当我试图得到它的错误.

ring.cpp: In function ‘void init_module_ring()’:
ring.cpp:130:16: error: wrong number of template arguments (1, should be 4)
 class_<Ring>("Ring").Please help me. Thanks in Advance.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

#include <boost/python/def.hpp>
#include<iostream>
using namespace std;
using namespace boost::python;


template <class T>
class Ring
   {
   public:
   class iterator;
   public:
    unsigned int m_size;
    unsigned int pos;
    T *val;
    Ring():
    m_size(0),pos(0),val(NULL){};
    Ring(int size):m_size(size),pos(0){
        val=new T[m_size];
    };
    Ring(const Ring &other)
        {
        this->m_size = other.m_size;
        this->pos= other.pos;
        this->val = other.val;

        }
    ~Ring()
        {
        delete[] val;
        }
    void insert(T data)
        { …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-python

5
推荐指数
1
解决办法
730
查看次数

使用Swift的for循环中的两个变量

如何在for循环中使用两个变量?

for j,k in zip(range(x,0,-1),range(y,-1,-1) 
Run Code Online (Sandbox Code Playgroud)

我想在Swift中实现它.

swift swift-playground swift2

2
推荐指数
1
解决办法
2944
查看次数

标签 统计

boost ×1

boost-python ×1

c++ ×1

swift ×1

swift-playground ×1

swift2 ×1