Re: Something to remember...
Quote:
Originally posted by KevinHall
According to Scott Meyers, STL containers of auto-pointers are forbidden by the C++ standard.
Correct, but there are some buggy compilers that let you declare one anyway, and merrily let you shoot yourself in the foot when you run your app.
Regards,
Paul McKenzie
Re: Re: Something to remember...
Quote:
Originally posted by Paul McKenzie
Correct, but there are some buggy compilers that let you declare one anyway, and merrily let you shoot yourself in the foot when you run your app.
Very true! I just wanted to let people know that it's not just a bad idea to use containers of auto_ptr's, but it is forbidden (despite non-compliant compilers). ;)
- Kevin
Re: Re: Re: Something to remember...
Quote:
Originally posted by KevinHall
Very true! I just wanted to let people know that it's not just a bad idea to use containers of auto_ptr's, but it is forbidden (despite non-compliant compilers). ;)
- Kevin
Why did you say it was forbidden ?
May I ask ?
Thanks,
-FionA
Re: Re: Re: Re: Something to remember...
Quote:
Originally posted by Homestead
Why did you say it was forbidden ?
May I ask ?
The short answer is that auto_ptrs are forbidden as container elements because they don't work there :).
This has to do with how auto_ptrs are copied. When you copy an auto_ptr you do get a copy but the auto_ptr you copied from will change. So after the copy the two auto_ptrs still will be different. And this has to do with a basic requirement: Two auto_ptrs may not point to the same object.