Update of /cvsroot/boost/boost/libs/smart_ptr/test
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16436/test

Modified Files:
        smart_ptr_test.cpp 
Log Message:
Fix C++0x ambiguity between boost::shared_ptr and std::shared_ptr

Index: smart_ptr_test.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/smart_ptr/test/smart_ptr_test.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- smart_ptr_test.cpp  10 Aug 2004 10:34:18 -0000      1.5
+++ smart_ptr_test.cpp  6 Apr 2007 00:23:17 -0000       1.6
@@ -51,12 +51,6 @@
   return incomplete.get();
 }
 
-using namespace std;
-using boost::scoped_ptr;
-using boost::scoped_array;
-using boost::shared_ptr;
-using boost::shared_array;
-
 template<class T>
 void ck( const T* v1, T v2 ) { BOOST_TEST( *v1 == v2 ); }
 
@@ -72,7 +66,7 @@
   explicit UDT( long value=0 ) : value_(value) { ++UDT_use_count; }
   ~UDT() {
     --UDT_use_count;
-    cout << "UDT with value " << value_ << " being destroyed\n";
+    std::cout << "UDT with value " << value_ << " being destroyed\n";
     }
   long value() const { return value_; }
   void value( long v ) { value_ = v;; }
@@ -86,16 +80,16 @@
 
 class Incomplete;
 
-Incomplete * check_incomplete( scoped_ptr<Incomplete>& incomplete )
+Incomplete * check_incomplete( boost::scoped_ptr<Incomplete>& incomplete )
 {
   return incomplete.get();
 }
 
-Incomplete * check_incomplete( shared_ptr<Incomplete>& incomplete,
-                               shared_ptr<Incomplete>& i2 )
+Incomplete * check_incomplete( boost::shared_ptr<Incomplete>& incomplete,
+                               boost::shared_ptr<Incomplete>& i2 )
 {
   incomplete.swap(i2);
-  cout << incomplete.use_count() << ' ' << incomplete.unique() << '\n';
+  std::cout << incomplete.use_count() << ' ' << incomplete.unique() << '\n';
   return incomplete.get();
 }
 
@@ -107,7 +101,7 @@
 
     //  test scoped_ptr with a built-in type
     long * lp = new long;
-    scoped_ptr<long> sp ( lp );
+    boost::scoped_ptr<long> sp ( lp );
     BOOST_TEST( sp.get() == lp );
     BOOST_TEST( lp == sp.get() );
     BOOST_TEST( &*sp == lp );
@@ -122,7 +116,7 @@
     BOOST_TEST( sp.get() == 0 );
 
     //  test scoped_ptr with a user defined type
-    scoped_ptr<UDT> udt_sp ( new UDT( 999888777 ) );
+    boost::scoped_ptr<UDT> udt_sp ( new UDT( 999888777 ) );
     BOOST_TEST( udt_sp->value() == 999888777 );
     udt_sp.reset();
     udt_sp.reset( new UDT( 111222333 ) );
@@ -132,7 +126,7 @@
 
     //  test scoped_array with a build-in type
     char * sap = new char [ 100 ];
-    scoped_array<char> sa ( sap );
+    boost::scoped_array<char> sa ( sap );
     BOOST_TEST( sa.get() == sap );
     BOOST_TEST( sap == sa.get() );
 
@@ -152,7 +146,7 @@
 
     //  test shared_ptr with a built-in type
     int * ip = new int;
-    shared_ptr<int> cp ( ip );
+    boost::shared_ptr<int> cp ( ip );
     BOOST_TEST( ip == cp.get() );
     BOOST_TEST( cp.use_count() == 1 );
 
@@ -162,7 +156,7 @@
     ck( static_cast<int*>(cp.get()), 54321 );
     ck( static_cast<int*>(ip), *cp );
 
-    shared_ptr<int> cp2 ( cp );
+    boost::shared_ptr<int> cp2 ( cp );
     BOOST_TEST( ip == cp2.get() );
     BOOST_TEST( cp.use_count() == 2 );
     BOOST_TEST( cp2.use_count() == 2 );
@@ -172,7 +166,7 @@
     ck( static_cast<int*>(cp2.get()), 54321 );
     ck( static_cast<int*>(ip), *cp2 );
 
-    shared_ptr<int> cp3 ( cp );
+    boost::shared_ptr<int> cp3 ( cp );
     BOOST_TEST( cp.use_count() == 3 );
     BOOST_TEST( cp2.use_count() == 3 );
     BOOST_TEST( cp3.use_count() == 3 );
@@ -202,20 +196,20 @@
     BOOST_TEST( cp.use_count() == 3 );
     BOOST_TEST( *cp == 87654 );
 
-    shared_ptr<int> cp4;
+    boost::shared_ptr<int> cp4;
     swap( cp2, cp4 );
     BOOST_TEST( cp4.use_count() == 3 );
     BOOST_TEST( *cp4 == 87654 );
     BOOST_TEST( cp2.get() == 0 );
 
-    set< shared_ptr<int> > scp;
+    std::set< boost::shared_ptr<int> > scp;
     scp.insert(cp4);
     BOOST_TEST( scp.find(cp4) != scp.end() );
-    BOOST_TEST( scp.find(cp4) == scp.find( shared_ptr<int>(cp4) ) );
+    BOOST_TEST( scp.find(cp4) == scp.find( boost::shared_ptr<int>(cp4) ) );
 
     //  test shared_array with a built-in type
     char * cap = new char [ 100 ];
-    shared_array<char> ca ( cap );
+    boost::shared_array<char> ca ( cap );
     BOOST_TEST( ca.get() == cap );
     BOOST_TEST( cap == ca.get() );
     BOOST_TEST( &ca[0] == cap );
@@ -227,8 +221,8 @@
     BOOST_TEST( ca[0] == 'H' );
     BOOST_TEST( ca[30] == 'h' );
 
-    shared_array<char> ca2 ( ca );
-    shared_array<char> ca3 ( ca2 );
+    boost::shared_array<char> ca2 ( ca );
+    boost::shared_array<char> ca3 ( ca2 );
 
     ca[0] = 'N';
     ca[4] = 'd';
@@ -246,24 +240,24 @@
     ca.reset();
     BOOST_TEST( ca.get() == 0 );
 
-    shared_array<char> ca4;
+    boost::shared_array<char> ca4;
     swap( ca3, ca4 );
     BOOST_TEST( ca4.use_count() == 1 );
     BOOST_TEST( strcmp( ca4.get(), "Not dog with mustard and relish" ) == 0 );
     BOOST_TEST( ca3.get() == 0 );
 
-    set< shared_array<char> > sca;
+    std::set< boost::shared_array<char> > sca;
     sca.insert(ca4);
     BOOST_TEST( sca.find(ca4) != sca.end() );
-    BOOST_TEST( sca.find(ca4) == sca.find( shared_array<char>(ca4) ) );
+    BOOST_TEST( sca.find(ca4) == sca.find( boost::shared_array<char>(ca4) ) );
 
     //  test shared_array with user defined type
-    shared_array<UDT> udta ( new UDT[3] );
+    boost::shared_array<UDT> udta ( new UDT[3] );
 
     udta[0].value( 111 );
     udta[1].value( 222 );
     udta[2].value( 333 );
-    shared_array<UDT> udta2 ( udta );
+    boost::shared_array<UDT> udta2 ( udta );
 
     BOOST_TEST( udta[0].value() == 111 );
     BOOST_TEST( udta[1].value() == 222 );
@@ -280,7 +274,7 @@
 
     //  test shared_ptr with a user defined type
     UDT * up = new UDT;
-    shared_ptr<UDT> sup ( up );
+    boost::shared_ptr<UDT> sup ( up );
     BOOST_TEST( up == sup.get() );
     BOOST_TEST( sup.use_count() == 1 );
 
@@ -288,7 +282,7 @@
     BOOST_TEST( sup->value() == 54321 );
     BOOST_TEST( up->value() == 54321 );
 
-    shared_ptr<UDT> sup2;
+    boost::shared_ptr<UDT> sup2;
     sup2 = sup;
     BOOST_TEST( sup2->value() == 54321 );
     BOOST_TEST( sup.use_count() == 2 );
@@ -298,7 +292,7 @@
     BOOST_TEST( sup.use_count() == 2 );
     BOOST_TEST( sup2.use_count() == 2 );
 
-    cout << "OK\n";
+    std::cout << "OK\n";
 
     new char[12345]; // deliberate memory leak to verify leaks detected
 }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to