[Assorted-commits] SF.net SVN: assorted:[1271] sandbox/trunk/src/cc/rvaluerefs.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-03-09 00:27:46
|
Revision: 1271 http://assorted.svn.sourceforge.net/assorted/?rev=1271&view=rev Author: yangzhang Date: 2009-03-09 00:27:31 +0000 (Mon, 09 Mar 2009) Log Message: ----------- added rvalue ref demo Added Paths: ----------- sandbox/trunk/src/cc/rvaluerefs.cc Added: sandbox/trunk/src/cc/rvaluerefs.cc =================================================================== --- sandbox/trunk/src/cc/rvaluerefs.cc (rev 0) +++ sandbox/trunk/src/cc/rvaluerefs.cc 2009-03-09 00:27:31 UTC (rev 1271) @@ -0,0 +1,29 @@ +// Demo that in gcc 4.3 rvalue references are not quite up to spec. In +// particular, move() doesn't seem to be required anywhere. + +struct A {}; +void bar(A &&) {} +void foo(A &&a) { bar(a); } + +struct B { + B() : p(0) {} + B(B &&b) : p(b.p) {} +private: + void *p; + B(const B&); +}; + +int main() { + { + A a; + A &&b = a; + foo(a); + foo(b); + } + { + B a; + B b; + b = a; + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |