MESSAGE
DATE | 2016-12-10 |
FROM | Ruben Safir
|
SUBJECT | Subject: [Learn] const puzzle and literal type arguments
|
From learn-bounces-at-nylxs.com Sat Dec 10 19:33:55 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id BE5D2161312; Sat, 10 Dec 2016 19:33:54 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id E8C18160E77 for ; Sat, 10 Dec 2016 19:33:51 -0500 (EST) From: Ruben Safir To: learn-at-nylxs.com Message-ID: <8bfb4e78-9580-0ec1-a633-60da2e4e8773-at-mrbrklyn.com> Date: Sat, 10 Dec 2016 19:33:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 Subject: [Learn] const puzzle and literal type arguments X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
Section 12.2.1 Reference Arguments 317 BS
void f(const vector&); void f(vector&&); // (non-const) lvalue reference argument // const lvalue reference argument // rvalue reference argument void g(vector& vi, const vector& cvi) { f(vi); // call f(vector&) f(vci); // call f(const vector&) f(vector{1,2,3,4}); // call f(vector&&); } We must assume that a function will modify an rvalue argument, leaving it good only for de- struction or reassignment (=C2=A717.5). The most obvious use of rvalue references is to define move constructors and move assignments (=C2=A73.3.2, =C2=A717.5.2). I=E2=80=99m = sure someone will find a clever use for const-rvalue-reference arguments, but so far, I have not seen a genuine use case. Please note that for a template argument T, the template argument type deduction rules give T&& a significantly different meaning from X&& for a type X (=C2=A723.5.2.1). F= or template arguments, an rvalue reference is most often used to implement =E2=80=98=E2=80=98perfect = forwarding=E2=80=99=E2=80=99 (=C2=A723.5.2.1, =C2=A728.6.3).
-- =
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013
-- =
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 _______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|