
On 5/25/2011 5:42 PM, Darren Garvey wrote:
I believe he has already (modulo if he incorporated the minor change I mentioned): https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/example/ben...
I agree though, it isn't clear that your code is representative of "real" code. You should try not using templates - which take function pointers - to do the work and inline the code into the tests *.
It would be interesting to see the assembly produced by your compiler (I'm not sure you've said which one you're using) in a fully optimised release build of the tests too, just to see what's going on under the hood.
Sorry for the delay but here is the assembler dump in release mode of both functions: *** worked_make ***: push %r12 xor %r12d,%r12d push %rbp xor %ebp,%ebp push %rbx nopl 0x0(%rax) mov $0x4,%edi callq 0x405288 <_Znwm@plt> (operator new) mov %rax,%rbx xor %edi,%edi callq 0x405058 <_ZdlPv@plt> (operator delete) cmp %rbx,%r12 je 0x406464 <void worker_make<std::auto_ptr<int>, &(std::auto_ptr<int> make_auto<int>())>()+52> mov %r12,%rdi mov %rbx,%r12 callq 0x405058 <_ZdlPv@plt> (operator delete) xor %edi,%edi add $0x1,%ebp callq 0x405058 <_ZdlPv@plt> (operator delete) cmp $0x186a0,%ebp jne 0x406440 <void worker_make<std::auto_ptr<int>, &(std::auto_ptr<int> make_auto<int>())>()+16> pop %rbx pop %rbp mov %r12,%rdi pop %r12 jmpq 0x405058 <_ZdlPv@plt> (operator delete) mov %rax,%rbx mov %r12,%rdi callq 0x405058 <_ZdlPv@plt> (operator delete) mov %rbx,%rdi callq 0x405298 <_Unwind_Resume@plt> *** worker_new ***: push %r12 xor %r12d,%r12d push %rbp xor %ebp,%ebp push %rbx nopl 0x0(%rax) mov $0x4,%edi callq 0x405288 <_Znwm@plt> (operator new) cmp %rax,%r12 mov %rax,%rbx je 0x405e4d <void worker_new<std::auto_ptr<int>, int>()+45> mov %r12,%rdi mov %rbx,%r12 callq 0x405058 <_ZdlPv@plt> (operator delete) add $0x1,%ebp cmp $0x186a0,%ebp jne 0x405e30 <void worker_new<std::auto_ptr<int>, int>()+16> pop %rbx pop %rbp mov %r12,%rdi pop %r12 jmpq 0x405058 <_ZdlPv@plt> (operator delete) mov %rax,%rbx mov %r12,%rdi callq 0x405058 <_ZdlPv@plt> (operator delete) mov %rbx,%rdi callq 0x405298 <_Unwind_Resume@plt> -Phil