Ops,<br>Sorry disregards previous message...fat fingers...<br><br>I Hi,<br>I have a class template with a member function template as follow<br><br>template<class A, class B><br>class test {<br>public:<br><br> ........ Some member functions
<br><br> template<class L><br> L keys() const {<br> L list;<br> .....<br> return L;<br>};<br><br><br>I created a function to export the template in the following way<br><br>template<class A, class B, class L>
<br>void export_test(string name) {<br><br>typedef test<A,B> etest;<br><br>class_<etest>(name.c_str())<br> ..... Implemented all the member functions<br> .def("keys", &etest::keys<L>) **** trying to implement the member function template
<br>;<br><br>}<br><br>and used the export_test class to export to python. For example<br><br>export_test<double,double>("test_real");<br><br>Everything works fine if I comment<br>.def("keys", &etest::keys<L>)
<br>in the export_test. All the member functions of test are available in Python.<br><br>However if I insert the .def("keys", &etest::keys<L>) the code will not compile!!!<br><br>Am I missing something?
<br><br>Thanks Luca<br><br><br><br><br><br><br><div><span class="gmail_quote">On 29/08/2007, <b class="gmail_sendername">Luca Sbardella</b> <<a href="mailto:luca.sbardella@gmail.com">luca.sbardella@gmail.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>I have a class template with a function template as follow<br><br>template<class A, ...., class Z>
<br>class test {<br>public:<br> typedef D key_type;
<br> typedef T data_type;<br> typedef keyvaluepair<D,T> value_type;<br> typedef typename vector_composite<value_type>::container container;
<br> typedef typename container::iterator iterator;<br> typedef typename container::const_iterator const_iterator;<br> <br> dataserie(){}
<br> //<br> /// \brief search for a key_type<br> /// @return If the return value is not negative than it represents the index associated with the value_type d,<br> /// otherwise idx = -return-1 representes the index where the element would be inserted if added to the container.
<br> qm_long search(const key_type& key) const;<br> /// \brief check whether the value_type d is available<br> bool contains(const key_type& key) const {if(this->search(key)<0) return false; return true;}
<br> /// \brief get the index associated with the key_type t<br> qm_Size index(const key_type& t) const;<br> /// @param Time in years @returns the index i such that grid[i] is closest to t
<br> qm_Size closestIndex(const key_type& t) const;<br> /// @param Time in years @return closest time on grid<br> const value_type& closestValue(const key_type& t) const { return this->get(this->closestIndex(t));}
<br> <br> /// \brief The Add method<br> /// This member function should be used to add new elements to the timeserie<br> /// @param d The date<br> /// @param value The value associated with d
<br> void add(const key_type& key, const data_type& value = data_type());<br> <br> template<class L><br> L keys() const {<br> L list;<br> //for(const_iterator it = this->begin();it!=this->end();++it)
list.append(it->key());<br> return list;<br> }<br> <br> //template<class L><br> //L values() {return m_values.dataToList<L>();}<br> protected:<br> void insert(qm_Size pos, const value_type& kv) { this->vector().insert(this->vector().begin()+pos,kv);}
<br> };<br><br>
</blockquote></div><br>