[C++-sig] Re: abstract templates and pyste question.

David Abrahams dave at boost-consulting.com
Tue Feb 17 17:33:31 CET 2004


Nicodemus <nicodemus at esss.com.br> writes:

> Hanz Meizer wrote:
>
>> [...]
>>
>>>> ----------------------------------------------------
>>>> template<class T>
>>>> class PreProcessor
>>>> {
>>>> public:
>>>>   PreProcessor() {}
>>>>   virtual ~PreProcessor() {}
>>>>
>>>>   virtual const int getSize(void) = 0;
>>>>   virtual T* getObject(int id) = 0;
>>>> };
>>>> ----------------------------------------------------
>>>>
>>
>> I get the following error output:
>> --------------------------------------------------------------------
> pytest_p.cpp:41:   instantiated from here
> /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59:
> error: cannot
>     declare field `
>     boost::python::objects::value_holder_back_reference<PreProcessor<char>,
>     <unnamed>::PreProcessor_char_Wrapper>::m_held' to be of type `
>     <unnamed>::PreProcessor_char_Wrapper'
> /home/thomast/work/pyste/boost.current/boost/python/object/value_holder.hpp:59:
> error:
>      because the following virtual functions are abstract:
> TClass.h:72: error:     const int PreProcessor<T>::getSize() [with T = char]
> TClass.h:73: error:     T* PreProcessor<T>::getObject(int) [with T = char]
> make: *** [pytest_p.o] Error 1
> >> error--------------------------------------------------------------------
>>
>> As far as I understand it, the compiler expects that the template
>> can be instantiated. Looking into the pytes_p.cpp (which was
>> generated with pyste):
>>
>>     class_< PreProcessor<char>, boost::noncopyable,
>> PreProcessor_char_Wrapper >("PreProcessor_char", init<  >())
>>
>> Shouldn't this read no_init? I'm confused :(

There are two choices:

  1. It can be no_init

  2. PreProcessor_char_Wrapper must define getSize() and getObject()

Clearly, whatever was generated by pyste does neither of these.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list