Topic: 0x unique_ptr's implementation defined pointer


Author: "george.ryan@gmail.com" <george.ryan@gmail.com>
Date: Mon, 25 May 2009 16:24:34 CST
Raw View
Under 20.7.12.2, the declaration of unique_ptr shows:

template <class T, class D = default_delete<T>>
class unique_ptr {
public:
   typedef implementation-defined pointer;
   // ....
   explicit unique_ptr( pointer p );
   // ...
};

Why is the pointer type implementation defined?

Under the shared_ptr declaration in 20.7.13.2, the constructor is
template <class Y> explicit shared_ptr(Y* p);

Why the difference? What am I missing?

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Pete Becker <pete@versatilecoding.com>
Date: Tue, 26 May 2009 10:39:41 CST
Raw View
george.ryan@gmail.com wrote:
> Under 20.7.12.2, the declaration of unique_ptr shows:
>
> template <class T, class D = default_delete<T>>
> class unique_ptr {
> public:
>    typedef implementation-defined pointer;
>    // ....
>    explicit unique_ptr( pointer p );
>    // ...
> };
>
> Why is the pointer type implementation defined?
>

Looks like it should be "see below" rather than
"implementation-defined". See [unique.ptr.single]/3 for the details.

--
    Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: daniel.kruegler@googlemail.com
Date: Tue, 26 May 2009 10:38:51 CST
Raw View
On May 26, 12:24 am, "george.r...@gmail.com" <george.r...@gmail.com>
wrote:
> Under 20.7.12.2, the declaration of unique_ptr shows:
>
> template <class T, class D = default_delete<T>>
> class unique_ptr {
> public:
>    typedef implementation-defined pointer;
>    // ....
>    explicit unique_ptr( pointer p );
>    // ...
>
> };
>
> Why is the pointer type implementation defined?

IMO the term "implementation-defined" is incorrect
here and it should be replaced by "see below". If
you check out [unique.ptr.single]/3 you find:

"If the type remove_reference<D>::type::pointer exists, then
unique_ptr<T, D>::pointer shall be a synonym for
remove_reference<D>::type::pointer. Otherwise
unique_ptr<T, D>::pointer shall be a synonym for T*. The
type unique_ptr<T, D>::pointer shall be CopyConstructible
(Table 20.2.9) and CopyAssignable (Table 20.2.9).

So unique_ptr is not necessarily holding a T*.
You can customize it with a "pointer-like" type
satisfying above requirements.

> Under the shared_ptr declaration in 20.7.13.2,

In N2857 this is 20.8.13.2 and for this discussion I
assume you mean that.

> the constructor is
> template <class Y> explicit shared_ptr(Y* p);
>
> Why the difference? What am I missing?

Shared_ptr does not have a separate template
parameter for a deleter, so it is not possible to
provide a more general indirection of what the
underlying pointer type is compared to
unique_ptr..

HTH & Greetings from Bremen,

Daniel Kr   gler


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: "george.ryan@gmail.com" <george.ryan@gmail.com>
Date: Fri, 29 May 2009 08:25:56 CST
Raw View
On May 26, 1:39 pm, Pete Becker <p...@versatilecoding.com> wrote:

> Looks like it should be "see below" rather than
> "implementation-defined". See [unique.ptr.single]/3 for the details.

Hurray, I found a typo! I'm going to be famous. :-)

Is there someone I (or someone else here) can contact to make sure
that this gets fixed? No sense on letting it get caught here and
forgotten about.


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Jerry Coffin <jcoffin@taeus.com>
Date: Fri, 29 May 2009 11:35:08 CST
Raw View
In article <ffafd49a-ae0f-400c-9ab3-197447ce44b6
@s20g2000vbp.googlegroups.com>, george.ryan@gmail.com says...
> On May 26, 1:39 pm, Pete Becker <p...@versatilecoding.com> wrote:
>
> > Looks like it should be "see below" rather than
> > "implementation-defined". See [unique.ptr.single]/3 for the details.
>
> Hurray, I found a typo! I'm going to be famous. :-)
>
> Is there someone I (or someone else here) can contact to make sure
> that this gets fixed? No sense on letting it get caught here and
> forgotten about.

Pete Becker is the current editor of the draft standard, so I'm pretty
sure it's already gotten to exactly the right place to be sure it won't
get lost.

--
   Later,
   Jerry.

The universe is a figment of its own imagination.

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Pete Becker <pete@versatilecoding.com>
Date: Fri, 29 May 2009 16:25:03 CST
Raw View
Jerry Coffin wrote:
>
> In article <ffafd49a-ae0f-400c-9ab3-197447ce44b6
> @s20g2000vbp.googlegroups.com>, george.ryan@gmail.com says...
>>
>> On May 26, 1:39 pm, Pete Becker <p...@versatilecoding.com> wrote:
>>
>>> Looks like it should be "see below" rather than
>>> "implementation-defined". See [unique.ptr.single]/3 for the details.
>>
>> Hurray, I found a typo! I'm going to be famous. :-)
>>
>> Is there someone I (or someone else here) can contact to make sure
>> that this gets fixed? No sense on letting it get caught here and
>> forgotten about.
>
> Pete Becker is the current editor of the draft standard, so I'm pretty
> sure it's already gotten to exactly the right place to be sure it won't
> get lost.
>

In fact, I fixed it just an hour ago.

--
 Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]