Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: "Alex Blekhman" <tkfx.N05P4M@xxxxxxxxx>
- Date: Thu, 23 Jun 2005 14:19:31 +0300
P.J. Plauger wrote:
> Alex Blekhman wrote:
>> Requirements are strict indeed. However, in my opinion,
>> they ought not to prohibit certain freedom completely.
>> Currently, auto_ptr hinders to return anything but T*
>> from operator&. I can't see any benefit to auto_ptr in
>> doing that.
>
> Good, write a version that doesn't and propose it to
> WG21. The fact is that auto_ptr barely works as it
> stands. It intentionally relies on a creative
> interpretation of the antepenultimate draft of the C++
> Standard which *no* compiler actually implemented at the
> time. VC++ could support auto_ptr without kludges only
> with V7.1. The design is an attempt to merge two or three
> (of about 32) different use cases onto one class.
> Naturally, it barely works for any one of those use
> cases.
That changes the picture. I can understand constraints that
different compilers and/or usage patterns can impose on
"one-size-fits-all" class.
> Overloading operator& is *always* dangerous in C++. Using
> auto_ptr for anything other than assured destruction of an
> allocated object is equally dangerous. Feel free to
> criticize the style with which auto_ptr is implemented,
> or the design decisions that went into the current spec.
> But until you can make something sing and dance that's
> arguably better, your opinion doesn't carry a lot of
> weight (IMO).
It was not just criticizing in sake of criticizing. I'm far
from competing with you in C++ field considering your
experience and you're being one of leading persons in the
industry. I honestly tried to understand auto_ptr
implementation. When writing my own code I frequently look
at STL classes to learn how things may be acomplished and
why it's done in this way and not in another one. I was
writing kind of smart pointer, so naturally I peeked at
auto_ptr implementation for insights and was stumbled upon
by auto_ptr::operator->. "Should I do it in my code, too?",
"Is it by omission or on purpose? If on purpose, then what
is the purpose?" - these question I asked myself. After
thinking about it and trying to find the answer in
literature I still wasn't able to figure out the reason. So,
I posted the question in this NG. I'll take for granted your
answer that dereference there is for reason. Probably, some
day I'll find the case where it manifest itself.
Thanks kindly for your reply.
.
- Follow-Ups:
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: P.J. Plauger
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- References:
- Why there is dereference in std::auto_ptr::operator->() ?
- From: Alex Blekhman
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Carl Daniel [VC++ MVP]
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Alex Blekhman
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Tom Widmer [VC++ MVP]
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Alex Blekhman
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Tom Widmer [VC++ MVP]
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Carl Daniel [VC++ MVP]
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Tom Widmer [VC++ MVP]
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: P.J. Plauger
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: Alex Blekhman
- Re: Why there is dereference in std::auto_ptr::operator->() ?
- From: P.J. Plauger
- Why there is dereference in std::auto_ptr::operator->() ?
- Prev by Date: Re: Please don't take offense...
- Next by Date: Typename not required in class header
- Previous by thread: Re: Why there is dereference in std::auto_ptr::operator->() ?
- Next by thread: Re: Why there is dereference in std::auto_ptr::operator->() ?
- Index(es):
Relevant Pages
|