auto pointer in c++
I am curious to know how an auto_ptr is implemented in c++. And i tried to find out where the source开发者_开发问答 of it is located in ubuntu 10.04. I could only find the .h file but couldn't find its implementation. where can i find it?
The .h file is almost certainly its implementation. auto_ptr
is a template. Since template implementations need to be included in full, they're normally in the .h files.
The auto_ptr
is a template, and the whole code is most likely in the header file.
You can check on libstdc++ 4.4 implementation here.
It is a template class, so the details are exposed in the header file: take a look.
It's a template, so it's all in the header.
Here's a reference to Scott Meyers's auto_ptr
精彩评论