From 3727017805223164486 X-Google-Thread: f78e5,516d54c6ff652958 X-Google-Attributes: gidf78e5,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!meganewsservers.com!feeder2.on.meganewsservers.com!news.alt.net!comp-std-cpp-robomod!not-for-mail From: "Sylvester Hesp" Newsgroups: comp.std.c++ Subject: Re: "moveable data type" in comparison with "r-value reference" Date: Thu, 12 Apr 2007 11:55:14 CST Organization: Altopia Corp. - Usenet Access - www.altopia.com Lines: 30 Approved: Fergus Henderson , moderator of comp.std.c++ Message-ID: <461e0500$0$79139$e4fe514c@news.xs4all.nl> References: X-Trace: 1176372480 news.xs4all.nl 79139 oisyn/[::ffff:213.201.137.74]:49925 X-Complaints-To: abuse@xs4all.nl Return-Path: X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Original-To: std-c++@mailman.ucar.edu Delivered-To: std-c++@mailman.ucar.edu X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-RFC2646: Format=Flowed; Response X-Virus-Scanned: amavisd-new at ucar.edu X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au Xref: g2news1.google.com comp.std.c++:8452 "Richard Smith" wrote in message news:gnfTh.824$NZ2.325@newsfe3-gui.ntli.net... > Just to correct a couple of typos that crept in. (I copied an old version > of the simple 'string' class into the post.) > >> string& operator=( string&& o ) >> { string(o).swap(*this); return *this; } > > And this needs another invocation of move: > > { string(std::move(o)).swap(*this); return *this; } > Just curious: why must a new (temporary) string be created? Wouldn't o.swap(*this) suffice? I've read the latest proposed wording (N2118), and I couldn't find anything about an expression like o.swap(*this) being ill-formed as o is an r-value reference. As a matter of fact, 5/7 specifically states that, in this case (for the purpose of this function), o is an lvalue of type string. Am I misinterpreting or missing something? - Sylvester Hesp --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]