Revision: 1213
http://assorted.svn.sourceforge.net/assorted/?rev=1213&view=rev
Author: yangzhang
Date: 2009-02-21 09:01:45 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
added smartptrs demo
Modified Paths:
--------------
sandbox/trunk/src/cc/smartptrs.cc
Modified: sandbox/trunk/src/cc/smartptrs.cc
===================================================================
--- sandbox/trunk/src/cc/smartptrs.cc 2009-02-20 22:43:34 UTC (rev 1212)
+++ sandbox/trunk/src/cc/smartptrs.cc 2009-02-21 09:01:45 UTC (rev 1213)
@@ -1,6 +1,24 @@
#include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
+// NOT what we want:
+// #include <boost/interprocess/smart_ptr/unique_ptr.hpp>
+#include <memory>
+#include <commons/boost/unique_ptr.hpp>
using namespace boost;
+// using namespace boost::interprocess;
+using namespace std;
int main() {
scoped_array<int> a(new int[5]);
+ scoped_array<int> b;
+ swap(a,b);
+
+ unique_ptr<int[]> u(new int[5]);
+
+ auto_ptr<int> p(new int(3));
+
+ // This doesn't work.
+ // scoped_ptr<int[]> p(new int[5]);
+
+ const scoped_ptr<int> s(new int[5]);
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|