
On 5/25/2011 4:15 PM, Phil Endecott wrote:
That effect should be immeasurably small, or eliminated entirely by the compiler.
I think you had better post your benchmark code. There must surely be something else going on here.
In debug mode I see that: 1) worker_name() run by auto_ptr calls the following on each iteration: - make_auto<int>() - operator new - auto_ptr::auto_ptr(int *) - operator auto_ptr_ref () - auto_ptr::auto_ptr(auto_ptr_ref()) - ~auto_ptr - auto_ptr_ref<int>() ... - auto_ptr<int>::operator = (auto_ptr_ref<int>) ... - auto_ptr<int>::~auto_ptr<int>() ... 2) worker_new() run by auto_ptr simply calls - operator new - auto_ptr<int>::reset(int *) I haven't debugged the release mode but we see that there is a lot of work to do to optimize worker_name() run by auto_ptr -Phil