Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #549

Re: C++11 Ranking implicit conversion sequences (13.3.3.2)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Tue, 02 Oct 2012 03:00:01 -0500
Return-Path <cppmods@mcgurn.dreamhost.com>
Sender std-cpp-request@vandevoorde.com
Approved james.dennett@gmail.com
Message-ID <k4bevl$jfl$1@dont-email.me> (permalink)
Newsgroups comp.std.c++
From Daniel Krügler <daniel.kruegler@googlemail.com>
Subject Re: C++11 Ranking implicit conversion sequences (13.3.3.2)
Organization A noiseless patient Spider
References <k4852m$2bs3$1@adenine.netfront.net>
Content-Type text/plain; charset=windows-1252; format=flowed
X-Original-Date Mon, 01 Oct 2012 08:59:01 +0200
X-Submission-Address std-cpp-submit@vandevoorde.com
To undisclosed-recipients:;
X-Spam-Status No, score=0.5 required=5.0 tests=FREEMAIL_FROM,HEADER_SPAM, RP_MATCHES_RCVD,SARE_HEAD_HDR_APPROV,UNPARSEABLE_RELAY autolearn=disabled version=3.3.1
X-Spam-Checker-Version SpamAssassin 3.3.1 (2010-03-16) on harlem.dreamhost.com
Date Tue, 2 Oct 2012 02:57:56 CST
Lines 76
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-n7hJ7LDVrQR4iwIb0xc7P0Vn8PBolWuHZIDGPOQyojVxkT1GQlnUjE9qqOL9IocfxbIo2WtOximHwx1!McchDZdOQlPyyZt54e6neD2aS7bfbDPuWrvaOxHZfxochAQtDAI=
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 4009
Xref csiph.com comp.std.c++:549

Show key headers only | View raw


On 2012-10-01 05:17, michael@mehlich.com wrote:
>
>
> The standard (actually earlier versions as well as the current github
> draft) provide the following statement in 13.3.3.2 for comparing
> conversion sequences:
>
> "Standard conversion sequence S1 is a better conversion sequence than
> standard conversion sequence S2 if ...
> S1 and S2 are reference bindings (8.5.3) and neither refers to an
> implicit object parameter of a non-static member function declared
> without a ref-qualifier, and S1 binds an rvalue reference to an
> rvalue and S2 binds an lvalue reference."
>
> This is immediately followed by the example:
>   int g(const int&);
>   int g(const int&&);
>   int j = g(i); // calls g(const int &)
> which is a preference of binding an lvalue reference to an lvalue over
> binding an rvalue reference to an lvalue.
>
> The above statement does not say anything about this preference, nor
> could I find any other statement in 13.3.3.2 that would provide this
> preference.


The wording here is indeed broken, as described by core issue

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1414

but for different reasons as you describe. Note that 13.3.3.2 p3 is
about valid conversion sequences, but binding of an lvalue of T to an
rvalue reference of T is no valid conversion sequence. The key part of
this example is the one that you have left out in your quotation,
namely

int k = g(f1()); // calls g(const int&&)
int l = g(f2()); // calls g(const int&&)

which demonstrates that rvalues are preferrably bound to rvalue
references. The first part about

int j = g(i); // calls g(const int&)

is just given to show how lvalues behave (It is not affected by this
rule). Note that similar examples that are not directly related to the
corresponding rule are also given at other places, like

a << 1; // calls A::operator<<(int)
a << ’c’; // calls A::operator<<(int)

or

a.p(); // calls A::p()&

> Did I miss something somewhere?
> What is the correct resolution rule for this?


Just strike "to an rvalue" from the current wording.

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                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Find similar


Thread

C++11 Ranking implicit conversion sequences (13.3.3.2) michael@mehlich.com - 2012-09-30 21:17 -0600
  Re: C++11 Ranking implicit conversion sequences (13.3.3.2) Daniel Krügler <daniel.kruegler@googlemail.com> - 2012-10-02 02:57 -0600

csiph-web