hjk41的日志

Avatar

Effective STL 3: Make copying cheap and correct for objects in containers

When you insert/push an object into a container, or when you move objects around the container, they get copied.

If copying for objects in containers, the time spent in copying the objects may greatly influence the performance of your program. To avoid this, you can use containers of pointers. However, containers of pointers have their own headaches, as you will see in Item 7. It will be better to use smart pointers.

评论已关闭