From -6318677877046408807
X-Google-Thread: f78e5,be8dba9addd8a207
X-Google-NewGroupId: yes
X-Google-Attributes: gid7894ca11fe,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Received: by 10.68.201.132 with SMTP id ka4mr191365pbc.8.1338315943235;
        Tue, 29 May 2012 11:25:43 -0700 (PDT)
MIME-Version: 1.0
Path: pr3ni63148pbb.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!news.albasani.net!.POSTED!not-for-mail
From: =?ISO-8859-1?Q?Daniel_Kr=FCgler?=<daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: Smart pointer comparison - why a difference?
Date: Tue, 29 May 2012 11:25:39 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 39
Sender: std-cpp-request@vandevoorde.com
Approved: stephen.clamage@oracle.com
Message-ID: <jq1tsb$uth$1@dont-email.me>
References: <a2i65qF4eeU1@mid.individual.net>
NNTP-Posting-Host: X/RiL1VE8fbEFzZRmEtibTMPTsBtapTp2vPC4/Q1Zro=
X-Trace: news.albasani.net 5JFq4Edh/2LyWyAcZJ1znHwqybul1iWP9IXVaosvxJmNdqsRSzeZfV1LdTZqF+k+CWdqziY3l5+ZNHbJYyFNAA==
X-Complaints-To: abuse@albasani.net
NNTP-Posting-Date: Tue, 29 May 2012 18:25:42 +0000 (UTC)
X-Mailer: Perl5 Mail::Internet v2.05
X-Submission-Address: std-cpp-submit@vandevoorde.com
Cancel-Lock: sha1:4oRx8DZat6sNunM51nbXNoVkpA0=
X-Original-Date: Tue, 29 May 2012 09:29:14 +0200
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 2012-05-28 23:53, Bo Persson wrote:
>  In C++11, operator<  for unique_ptr [unique.ptr.special] is defined as
>
>  std::less<CT>()(x.get(), y.get())
>
>  where CT is the common_type of the unique_ptr's internal pointer typedefs.
>
>
>  On the other hand, operator<  for shared_ptr [util.smartptr.shared.cmp]
>  is defined as
>
>  std::less<V>()(a.get(), b.get())
>
>  "where V is the composite pointer type (5.9) of T* and U*."
>
>
>  What exactly is the difference, and why?

The wording difference exists, because std::unique_ptr can hold both
built-in pointers and pointer-like types while std::shared_ptr can only
hold pointers. The intention is that unique_ptr's wording has exactly
the same effect when it holds a pointer. Currently these definitions are
not the same because of a wording defect of std::common_type. An issue
has already been raised for this but is not yet visible in the official
list. In short words, that defect is because std::common_type<int*,
int*>::type evaluates to int*&&  and not int*. This was an unintended
side-effect because of change of the original definition of the
conditional operator in the presence of xvalues.

HTH&  Greetings from Bremen,

Daniel Kr�gler


-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]


