Return-Path: X-Original-To: apmail-mesos-dev-archive@www.apache.org Delivered-To: apmail-mesos-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D13A186EF for ; Wed, 17 Jun 2015 18:17:02 +0000 (UTC) Received: (qmail 39314 invoked by uid 500); 17 Jun 2015 18:17:01 -0000 Delivered-To: apmail-mesos-dev-archive@mesos.apache.org Received: (qmail 39229 invoked by uid 500); 17 Jun 2015 18:17:01 -0000 Mailing-List: contact dev-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mesos.apache.org Delivered-To: mailing list dev@mesos.apache.org Received: (qmail 38679 invoked by uid 99); 17 Jun 2015 18:17:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2015 18:17:01 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of benjamin.mahler@gmail.com designates 209.85.160.172 as permitted sender) Received: from [209.85.160.172] (HELO mail-yk0-f172.google.com) (209.85.160.172) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jun 2015 18:14:46 +0000 Received: by ykar6 with SMTP id r6so46809831yka.2 for ; Wed, 17 Jun 2015 11:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=YFYOEY/nzd2DjCq5eFJ3Px653A4gWij9qAclQWeYzUc=; b=XQllXv75QHxAkmLd85WSt5m6G28P5VH0xXVoQn1SZPfQNcc1S1hdguCwVOwoUjCxit mAIDpbj6B9UZpWj8FxaOCwUqFXs+vilb9VfoW1J0rvWd98AH++zb4keHZBCItZj9s85W B/UeWXuBabTB3nifSU1sBe+B3inUus/+y6DJvpFG3fYydXpN2/KT1YKX7UhhIUshWl6r 2Lzwy3fUfZVYUIfC1PEdVWWnr/ZX99Bi5p8kTH3nq2+Xz4td32IJ/ObGswI3XKJW6Q72 zsTVnVhaLp8b5cCsPGHml918csSgAccZNk3+9wPVlB0tqJVD6hXu+IHrlM1IqxHvDxUU JyEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=YFYOEY/nzd2DjCq5eFJ3Px653A4gWij9qAclQWeYzUc=; b=dV+veUCB1veDN0kQTx/qQZtT82noSic9nZrlntYyr5gVO/oL9TeIyKUj/IhuRZZ0qS TNc8gjnkkqWShFzpMdx09a2HZSucoK6B56M6cHh3MyHvet+Fbc0DTKIZQ3XetFWt05bH 0ET7mE54m7PCJcc5dhgAZxoHg3n2Ql1fIpkNDwOSzzUcKQecSUi2fuvFGhZCQ1MauFv1 kDfFxP2XJxUcMGb+c6/858ViuvIQHBUVkeDNswsqsxtmDqE25Ci1RXWsfD4hLDe2mZJ3 Be1Z9OaBYk98gzZgw+MJa/s8UXtviPH5hzzNld6cdRkz7Kiarm86BrLQWWLb1pBojWk1 2k+g== X-Received: by 10.170.119.139 with SMTP id l133mr8659313ykb.89.1434564994564; Wed, 17 Jun 2015 11:16:34 -0700 (PDT) Received: from mail-yh0-f46.google.com (mail-yh0-f46.google.com. [209.85.213.46]) by mx.google.com with ESMTPSA id g187sm4075120ywf.35.2015.06.17.11.16.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jun 2015 11:16:34 -0700 (PDT) Received: by yhnv31 with SMTP id v31so13756576yhn.1 for ; Wed, 17 Jun 2015 11:16:34 -0700 (PDT) X-Gm-Message-State: ALoCoQksCAnL1woaiji86CrDynx43tGinYRl0bgMcVOfAa/aMKDl1SdOC7uvPjtQMJF5Gcl0wOV4 X-Received: by 10.170.233.10 with SMTP id z10mr8398672ykf.71.1434564994154; Wed, 17 Jun 2015 11:16:34 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.112.11 with HTTP; Wed, 17 Jun 2015 11:16:13 -0700 (PDT) In-Reply-To: <968A3D58-5BC4-4BE0-9FC2-089836C71A81@me.com> References: <2B3A80DD-3965-4922-A7DE-1E621C2CB5A0@mesosphere.io> <968A3D58-5BC4-4BE0-9FC2-089836C71A81@me.com> From: Benjamin Mahler Date: Wed, 17 Jun 2015 11:16:13 -0700 Message-ID: Subject: Re: Style guide for std::move To: dev Content-Type: multipart/alternative; boundary=001a113a80f6e25d5f0518bab088 X-Virus-Checked: Checked by ClamAV on apache.org --001a113a80f6e25d5f0518bab088 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Also, do we want to allow a re-assignment after a move to re-use the object= ? Just some food for thought, have you explored extending Option to capture this? Option> v {1, 2, 3, 4}; foo(v.move()); v.isSome(); // false v =3D {1, 2, 3, 4}; v.isSome() // true On Wed, Jun 17, 2015 at 7:19 AM, Till Toenshoff wrote: > +1 for 1. =E2=80=9Ctreat it like a deleted pointer=E2=80=9D > > > > On Jun 12, 2015, at 4:21 PM, Alexander Rojas > wrote: > > > > Hey guys, there have been questions on how to deal with std::move in th= e > code. Right now our style guide says nothing about it, but there is no > consensus in the reviews. The problem with std::move is that for all > standard library functions that accept rvalue references as parameters ar= e > guaranteed to leave the moved object in a valid but unspecified state (se= e > http://en.cppreference.com/w/cpp/utility/move < > http://en.cppreference.com/w/cpp/utility/move>). > > > > The following are some ideas into how to deal with moved objects > > > > 1. Treat std::move as a delete and stop using it after the move > > > > std::vector v{1, 2, 3, 4}; > > .., > > foo(std::move(v)); // Don=E2=80=99t use > > > > 2. Always create explicitly an scope the object to be moved, with the > first line being the definition of the object to be moved, and the last > line of the scope the move itself. > > > > if (bar()) { > > { > > std::vector v{1, 2, 3}; > > =E2=80=A6. > > foo(std::move(v)); > > } > > } > > > > 3. Create a scope for the if no scope already exists following the rule= s > of 2): > > > > if (bar()) { > > std::vector v{1, 2, 3}; > > =E2=80=A6. > > foo(std::move(v)); > > } > > > > --001a113a80f6e25d5f0518bab088--