From -147823705207673395 X-Google-Thread: f78e5,516d54c6ff652958 X-Google-Attributes: gidf78e5,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed.gamma.ru!Gamma.RU!newsfeed.icl.net!newsfeed.fjserv.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull From: news@news.demon.net ("News Admin") Newsgroups: comp.std.c++ Subject: Re: "moveable data type" in comparison with "r-value reference" Date: Sun, 15 Apr 2007 15:47:47 GMT Lines: 35 Sender: mail2news@demon.net Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: <87k5wi5kby.fsf@grogan.peloton> <1176485025.023050.11390@e65g2000hsc.googlegroups.com> NNTP-Posting-Host: news.news.demon.net Mime-Version: 1.0 Content-Type: text/plain; charset=Big5 Content-Transfer-Encoding: 7bit X-Trace: news.demon.co.uk 1176652076 15643 158.152.254.254 (15 Apr 2007 15:47:56 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 15 Apr 2007 15:47:56 +0000 (UTC) X-Original-To: std-c++@mailman.ucar.edu X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au X-Received: (from fjh@localhost) by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id l3FFllSC019571; Mon, 16 Apr 2007 01:47:47 +1000 (EST) X-Path: comp-std-cpp-robomod!not-for-mail X-NNTP-Posting-Date: Sat, 14 Apr 2007 21:50:21 +0000 (UTC) X-Delivered-To: std-c++@mailman.ucar.edu X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f X-Newsgroups: comp.std.c++ Xref: g2news1.google.com comp.std.c++:8493 wij@seed.net.tw wrote: > > Sorry for the interrupt. And I don't really understand rvalue > reference. > But to my part of understanding of the move constructor > 1.the moved-from source object must not be destroyed. E.g. > > class A { > static int count=0; > char* _cptr; > public: > A() : _cptr(NULL) { ++count; }; > ~A() { --count; }; > $A(A& src) : _cptr(src._cptr) {}; // $A denotes the move > constructor > } > > A* buf= new 10*sizeof(A); > new(&buf[0]) A(); // A[0] contains A(), other position is > uninitialized > > Then no matter how the only element (A[0]) is moved around in buf. > A::count should be 1. > > 2. For a non-default object becomes a default object, A destructor > call is involved in the general case. (throw might occur) But the author of the move ctor is responsible for ensuring that the moved source object is left in a destructable state. --- [ 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 ]