title: boost python with template class
body: <p>I created a ring buffer and I want to import that class to Python using boost. When I am trying to that its getting error. </p>
  
  <pre><code>ring.cpp: In function ‘void init_module_ring()’:
  ring.cpp:130:16: error: wrong number of template arguments (1, should be 4)
   class_&lt;Ring&gt;("Ring").Please help me. Thanks in Advance.
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;boost/python/def.hpp&gt;
  #include&lt;iostream&gt;
  using namespace std;
  using namespace boost::python;
  
  
  template &lt;class T&gt;
  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 &amp;other)
          {
          this-&gt;m_size = other.m_size;
          this-&gt;pos= other.pos;
          this-&gt;val = other.val;
  
          }
      ~Ring()
          {
          delete[] val;
          }
      void insert(T data)
          {
          val[pos]= data;
          pos++;
          if(pos==m_size)
          pos=0;
  
          }
      void displayall()
      {
         for(int i =0;i&lt;m_size;i++)
         {
         cout&lt;&lt;val[i]&lt;&lt;' ';
         }
      }
      iterator begin()
      {
         return iterator(val);
      }
      iterator end()
      {
         return iterator(val + m_size);
      }
      unsigned int size()
      {
         return m_size;
     }
     void check()
     {
        cout&lt;&lt;val&lt;&lt;' ';
        cout&lt;&lt;val+5;
     }
      };
  template&lt;class T&gt;
  class Ring&lt;T&gt;::iterator
  {
     T *it_value;
     public:
     iterator():it_value(NULL){};
     iterator(T *value)
     {
     it_value = value;
     };
     iterator(const iterator &amp;other)
     {
         this-&gt;it_value = other.it_value;
     }
     friend ostream&amp; operator&lt;&lt;(ostream &amp;out,iterator it)
        {
        out&lt;&lt;*it.it_value;
        return out;
        }
     iterator operator++()
        {
        it_value  +=1;
        return (iterator(it_value));
        }
     iterator operator++(const int x)
        {
        it_value = it_value+ x+1;
        return(iterator(it_value));
        }
     bool operator==(const iterator &amp;other) const
         {
         return (*it_value == *(other.it_value));
         };
     bool operator!=(const iterator &amp;other) const
     {
     return (!(*this == other));
     };
     iterator operator*()
        {
        return *this;
        }
     void display()
         {
         cout&lt;&lt;*it_value&lt;&lt;' ';
         }
  };
  
  BOOST_PYTHON_MODULE(ring)
  {
      class_&lt;Ring&gt;("Ring")
          template &lt;class T&gt;
          .def(init&lt;int&gt;())
          .def("insert", &amp;Ring::insert)
          .def("display_all", &amp;Ring::displayall)
      ;
  }
  </code></pre>