 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Axter Guest
|
Posted: Tue Apr 18, 2006 8:06 pm Post subject: tr1::shared_ptr and boost::shared_ptr |
|
|
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Alf P. Steinbach Guest
|
Posted: Tue Apr 18, 2006 9:06 pm Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
* Pete Becker:
| Quote: | Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
|
Oops, I didn't notice that.
Is there any hope of having a custom delete function added, as with
boost::shared_ptr?
For example, boost::shared_ptr can be used with a class with protected
or private destructor, without being a friend of that class, by passing
it a deallocation function that does have access to the destructor.
For new code it's presumably no big deal to add friendship for a
standard smart-pointer, but code that relies on the above technique with
boost::smart_ptr won't work by simply replacing with std::shared_ptr
(assuming that's what the TR1 shared_ptr will end up as).
In short, it will require workarounds for all code that now uses
boost::shared_ptr and relies on the custom deleter, when such code is to
be changed to use the standard shared_ptr. And if the class in question
can't be changed (adding friendship), then std::shared_ptr can't be
used. I think it would reflect badly on the standard library if one had
to use boost::shared_ptr /in addition/ to std::shared_ptr.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Tue Apr 18, 2006 9:06 pm Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Axter wrote:
| Quote: | What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
|
There is none. It's part of the TR1 spec.
--
Pete Becker
Roundhouse Consulting, Ltd.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Alberto Ganesh Barbati Guest
|
Posted: Wed Apr 19, 2006 12:06 am Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Pete Becker ha scritto:
| Quote: | Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
|
Uhm? In the latest publicly available draft of TR1 (dated 2005-06-24
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf)
tr1::shared_ptr definitely *has* support for custom deleters. In
particular, see clause 2.2.3.2. Are you saying that this feature has
been removed in a subsequent (non-publicly available) draft?
Ganesh
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Wed Apr 19, 2006 4:06 am Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Alf P. Steinbach wrote:
| Quote: | * Pete Becker:
Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
Oops, I didn't notice that.
Is there any hope of having a custom delete function added, as with
boost::shared_ptr?
|
Sorry, the earlier "It's part of the TR1 spec" referred to custom
deleters. They're in there.
--
Pete Becker
Roundhouse Consulting, Ltd.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Howard Hinnant Guest
|
Posted: Wed Apr 19, 2006 4:06 am Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
In article <4al25bFtp3o9U1 (AT) individual (DOT) net>,
"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote:
| Quote: | * Pete Becker:
Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
Oops, I didn't notice that.
Is there any hope of having a custom delete function added, as with
boost::shared_ptr?
|
I'm staring at TR1 right now. It says:
template<class T> class shared_ptr {
public:
...
template<class Y, class D> shared_ptr(Y* p, D d);
...
};
Is this not custom deleter support?
Or are we mistakenly talking about custom allocators?
-Howard
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Vaclav Haisman Guest
|
Posted: Wed Apr 19, 2006 4:06 am Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Axter wrote:
| Quote: | What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
Huh, without custom deleter it would be so much less useful. I find it |
useful for wrapping simple C stuff like FILE* and gdImage* with fclose()
resp. gdImageDestroy() as custom deleter.
--
VH
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Tom Widmer Guest
|
Posted: Wed Apr 19, 2006 3:06 pm Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Alberto Ganesh Barbati wrote:
| Quote: | Pete Becker ha scritto:
Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
Uhm? In the latest publicly available draft of TR1 (dated 2005-06-24
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf)
tr1::shared_ptr definitely *has* support for custom deleters. In
particular, see clause 2.2.3.2. Are you saying that this feature has
been removed in a subsequent (non-publicly available) draft?
|
There seems to be a misunderstanding. As a native english speaker, I
took Pete's comment to meant that:
1. There is no justification for the tr1 shared_ptr not to allow a
custom deleter like the boost::shared_ptr.
2. The custom deleter is part of the tr1::shared_ptr spec.
In other words, the OP asked an invalid question.
Tom
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Wed Apr 19, 2006 5:06 pm Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Alberto Ganesh Barbati wrote:
| Quote: | Pete Becker ha scritto:
Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
Uhm? In the latest publicly available draft of TR1 (dated 2005-06-24
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf)
tr1::shared_ptr definitely *has* support for custom deleters. In
particular, see clause 2.2.3.2. Are you saying that this feature has
been removed in a subsequent (non-publicly available) draft?
|
No, there's no justification for not allowing it because it is allowed.
--
Pete Becker
Roundhouse Consulting, Ltd.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Axter Guest
|
Posted: Thu Apr 20, 2006 4:06 pm Post subject: Re: tr1::shared_ptr and boost::shared_ptr |
|
|
Howard Hinnant wrote:
| Quote: | In article <4al25bFtp3o9U1 (AT) individual (DOT) net>,
"Alf P. Steinbach" <alfps (AT) start (DOT) no> wrote:
* Pete Becker:
Axter wrote:
What was the justification for the tr1 shared_ptr not to allow a custom
deleter like the boost::shared_ptr?
There is none. It's part of the TR1 spec.
Oops, I didn't notice that.
Is there any hope of having a custom delete function added, as with
boost::shared_ptr?
I'm staring at TR1 right now. It says:
template<class T> class shared_ptr {
public:
..
template<class Y, class D> shared_ptr(Y* p, D d);
..
};
Is this not custom deleter support?
Or are we mistakenly talking about custom allocators?
|
I remember previously reading a comparison between TR1::shared_ptr and
boost::shared_ptr, and reading something about tr1::shared_ptr not
having custom deleter.
I just did a google search for the link, but I can't find it now.
Maybe I misread it.
Thanks for the link and correction.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|