December 2001
Intermediate to advanced
304 pages
6h 25m
English
auto_ptr?Difficulty: 8
Does using auto_ptr help to solve the problem in Item 20?
As you continue to root through the archives, you see that someone must not have liked Item 20 Example 20-2 because later versions of the files in question were changed as follows:
// Example 21-1 // // In some header file: void f( auto_ptr<T1>, auto_ptr<T2> ); // In some implementation file: f( auto_ptr<T1>( new T1 ), auto_ptr<T2>( new T2 ) );
What improvements does this version offer over Item 20 Example 20-2, if any? Do any exception safety problems remain? Explain.
Demonstrate how to write an auto_ptr_new facility that solves the safety problems in Question 1 and can be invoked as follows:
// Example 21-2 ...
Read now
Unlock full access