Re: Error compiling dictionary for class with auto_ptr

From: Nicholas Devenish <misnomer_at_gmail.com>
Date: Fri, 5 Mar 2010 22:58:43 +0000


Hi Philippe,

Thanks for the quick response! That works perfectly!

Nick

On Fri, Mar 5, 2010 at 10:06 PM, Philippe Canal <pcanal_at_fnal.gov> wrote:

> Hi Nick,
>
> Currently cint does not support well auto_ptr, so you can simply hide the
> function from CINT:
>
> #include <memory>
>
> class test
> {
> public:
> #ifndef __CINT__
>
> std::auto_ptr<int> SomeFun(void) const;
> #endif
> };
>
> Cheers,
> Philippe.
>
>
> On 3/5/10 4:01 PM, Nicholas Devenish wrote:
>
>> Hi Roottalk,
>>
>> I'm getting an error compiling the dictionaries for a class that returns
>> an auto_ptr from a const function. The problem is with a member function of
>> the form:
>> std::auto_ptr<int> SomeFun(void) const;
>>
>> which results in the dictionary code:
>> const auto_ptr<int>* pobj;
>> const auto_ptr<int> xobj = ((const test*)
>> G__getstructoffset())->GetInt();
>> pobj = new auto_ptr<int>(xobj);
>>
>> Giving the error when trying to compile the third line:
>> error: passing ‘const std::auto_ptr<int>’ as ‘this’ argument of
>> ‘std::auto_ptr<int>::operator std::auto_ptr_ref<int>()’ discards qualifiers
>> because a non-const auto_ptr cannot be initialised by a const auto_ptr.
>>
>> Attached is a *very* small test file that exhibits this behaviour,
>> compiled with
>> rootcint out.cxx -c test.h
>> g++ -c out.cxx `root-config --cflags`
>>
>> Is there a way to get the dictionaries to compile properly?
>>
>> Thanks,
>>
>> Nick
>>
>>
>
Received on Fri Mar 05 2010 - 23:58:49 CET

This archive was generated by hypermail 2.2.0 : Mon Mar 08 2010 - 17:50:01 CET