|
Boost : |
From: Gregory Colvin (gregory.colvin_at_[hidden])
Date: 2003-10-13 16:52:31
On Monday, Oct 13, 2003, at 15:24 America/Denver, David Abrahams wrote:
> Gregory Colvin <gregory.colvin_at_[hidden]> writes:
>
>> On Monday, Oct 13, 2003, at 12:58 America/Denver, David Abrahams
>> wrote:
>>> Robert Ramey <ramey_at_[hidden]> writes:
>>>> David Abrahams wrote:
>>>>
>>>>>> template<class Archive ar, class T>
>>>>>> void load(Archive & ar, T * &t, unsigned int file_version)
>>>>>> {
>>>>>> t = NULL;
>>>>>> try{
>>>>>> t = new T();
>>>>>> ar >> *t;
>>>>>> }
>>>>>> catch(...){
>>>>>> delete t;
>>>>
>>>>> If you were to do it this way, you should do "t = NULL" here
>>>>> instead,
>>>>> but...
>> ...
>>>> hmm .. would you buy:
> ^^^
>>>>
>>>> template<class Archive ar, class T> // but see below
>>>> load(Archive & ar, T * & t, unsigned int file_version)
>>>> {
>>>> t = NULL;
>>>> std::auto_ptr<T> ta(new T());
>>>> ar >> *ta;
>>>> t = ta.release;
>>>> }
>>>
>>> I'd rather not pay for that one.
>>
>> Pay for what? GCC 3.1 produces very similar optimized code for both
>> the auto_ptr and explicit catch versions.
>
> I just mean I don't like the out parameter "t".
Aha. Neither do I.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk