THRIFT-2221: detect C++11 and use std namespace for memory operations (smart_ptr)
Client: C++

This closes #1328
diff --git a/lib/cpp/test/TSSLSocketInterruptTest.cpp b/lib/cpp/test/TSSLSocketInterruptTest.cpp
index bf5c7d7..85f6c39 100644
--- a/lib/cpp/test/TSSLSocketInterruptTest.cpp
+++ b/lib/cpp/test/TSSLSocketInterruptTest.cpp
@@ -19,13 +19,12 @@
 
 #include <boost/test/auto_unit_test.hpp>
 #include <boost/test/unit_test_suite.hpp>
-#include <boost/bind.hpp>
 #include <boost/chrono/duration.hpp>
 #include <boost/date_time/posix_time/posix_time_duration.hpp>
 #include <boost/thread/thread.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/format.hpp>
-#include <boost/shared_ptr.hpp>
+#include <thrift/stdcxx.h>
 #include <thrift/transport/TSSLSocket.h>
 #include <thrift/transport/TSSLServerSocket.h>
 #ifdef __linux__
@@ -38,6 +37,9 @@
 using apache::thrift::transport::TTransportException;
 using apache::thrift::transport::TSSLSocketFactory;
 
+using apache::thrift::stdcxx::static_pointer_cast;
+using apache::thrift::stdcxx::shared_ptr;
+
 BOOST_AUTO_TEST_SUITE(TSSLSocketInterruptTest)
 
 boost::filesystem::path keyDir;
@@ -92,7 +94,7 @@
 BOOST_GLOBAL_FIXTURE(GlobalFixtureSSL)
 #endif
 
-void readerWorker(boost::shared_ptr<TTransport> tt, uint32_t expectedResult) {
+void readerWorker(shared_ptr<TTransport> tt, uint32_t expectedResult) {
   uint8_t buf[4];
   try {
     tt->read(buf, 1);
@@ -102,7 +104,7 @@
   }
 }
 
-void readerWorkerMustThrow(boost::shared_ptr<TTransport> tt) {
+void readerWorkerMustThrow(shared_ptr<TTransport> tt) {
   try {
     uint8_t buf[400];
     tt->read(buf, 1);
@@ -113,8 +115,8 @@
   }
 }
 
-boost::shared_ptr<TSSLSocketFactory> createServerSocketFactory() {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory;
+shared_ptr<TSSLSocketFactory> createServerSocketFactory() {
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory;
 
   pServerSocketFactory.reset(new TSSLSocketFactory());
   pServerSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
@@ -124,8 +126,8 @@
   return pServerSocketFactory;
 }
 
-boost::shared_ptr<TSSLSocketFactory> createClientSocketFactory() {
-  boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory;
+shared_ptr<TSSLSocketFactory> createClientSocketFactory() {
+  shared_ptr<TSSLSocketFactory> pClientSocketFactory;
 
   pClientSocketFactory.reset(new TSSLSocketFactory());
   pClientSocketFactory->authenticate(true);
@@ -136,15 +138,15 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read_while_handshaking) {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
   TSSLServerSocket sock1("localhost", 0, pServerSocketFactory);
   sock1.listen();
   int port = sock1.getPort();
-  boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
-  boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
+  shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
+  shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
   clientSock->open();
-  boost::shared_ptr<TTransport> accepted = sock1.accept();
-  boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted));
+  shared_ptr<TTransport> accepted = sock1.accept();
+  boost::thread readThread(apache::thrift::stdcxx::bind(readerWorkerMustThrow, accepted));
   boost::this_thread::sleep(boost::posix_time::milliseconds(50));
   // readThread is practically guaranteed to be blocking now
   sock1.interruptChildren();
@@ -156,15 +158,15 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_read) {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
   TSSLServerSocket sock1("localhost", 0, pServerSocketFactory);
   sock1.listen();
   int port = sock1.getPort();
-  boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
-  boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
+  shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
+  shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
   clientSock->open();
-  boost::shared_ptr<TTransport> accepted = sock1.accept();
-  boost::thread readThread(boost::bind(readerWorkerMustThrow, accepted));
+  shared_ptr<TTransport> accepted = sock1.accept();
+  boost::thread readThread(apache::thrift::stdcxx::bind(readerWorkerMustThrow, accepted));
   clientSock->write((const uint8_t*)"0", 1);
   boost::this_thread::sleep(boost::posix_time::milliseconds(50));
   // readThread is practically guaranteed to be blocking now
@@ -177,17 +179,17 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_read) {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
   TSSLServerSocket sock1("localhost", 0, pServerSocketFactory);
   sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
   sock1.listen();
   int port = sock1.getPort();
-  boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
-  boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
+  shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
+  shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
   clientSock->open();
-  boost::shared_ptr<TTransport> accepted = sock1.accept();
-  boost::static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000);
-  boost::thread readThread(boost::bind(readerWorker, accepted, 0));
+  shared_ptr<TTransport> accepted = sock1.accept();
+  static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000);
+  boost::thread readThread(apache::thrift::stdcxx::bind(readerWorker, accepted, 0));
   clientSock->write((const uint8_t*)"0", 1);
   boost::this_thread::sleep(boost::posix_time::milliseconds(50));
   // readThread is practically guaranteed to be blocking here
@@ -203,14 +205,14 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_ssl_cannot_change_after_listen) {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
   TSSLServerSocket sock1("localhost", 0, pServerSocketFactory);
   sock1.listen();
   BOOST_CHECK_THROW(sock1.setInterruptableChildren(false), std::logic_error);
   sock1.close();
 }
 
-void peekerWorker(boost::shared_ptr<TTransport> tt, bool expectedResult) {
+void peekerWorker(shared_ptr<TTransport> tt, bool expectedResult) {
   uint8_t buf[400];
   try {
     tt->read(buf, 1);
@@ -220,7 +222,7 @@
   }
 }
 
-void peekerWorkerInterrupt(boost::shared_ptr<TTransport> tt) {
+void peekerWorkerInterrupt(shared_ptr<TTransport> tt) {
   uint8_t buf[400];
   try {
     tt->read(buf, 1);
@@ -231,15 +233,15 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_ssl_interruptable_child_peek) {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
   TSSLServerSocket sock1("localhost", 0, pServerSocketFactory);
   sock1.listen();
   int port = sock1.getPort();
-  boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
-  boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
+  shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
+  shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
   clientSock->open();
-  boost::shared_ptr<TTransport> accepted = sock1.accept();
-  boost::thread peekThread(boost::bind(peekerWorkerInterrupt, accepted));
+  shared_ptr<TTransport> accepted = sock1.accept();
+  boost::thread peekThread(apache::thrift::stdcxx::bind(peekerWorkerInterrupt, accepted));
   clientSock->write((const uint8_t*)"0", 1);
   boost::this_thread::sleep(boost::posix_time::milliseconds(50));
   // peekThread is practically guaranteed to be blocking now
@@ -252,17 +254,17 @@
 }
 
 BOOST_AUTO_TEST_CASE(test_ssl_non_interruptable_child_peek) {
-  boost::shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
+  shared_ptr<TSSLSocketFactory> pServerSocketFactory = createServerSocketFactory();
   TSSLServerSocket sock1("localhost", 0, pServerSocketFactory);
   sock1.setInterruptableChildren(false); // returns to pre-THRIFT-2441 behavior
   sock1.listen();
   int port = sock1.getPort();
-  boost::shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
-  boost::shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
+  shared_ptr<TSSLSocketFactory> pClientSocketFactory = createClientSocketFactory();
+  shared_ptr<TSSLSocket> clientSock = pClientSocketFactory->createSocket("localhost", port);
   clientSock->open();
-  boost::shared_ptr<TTransport> accepted = sock1.accept();
-  boost::static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000);
-  boost::thread peekThread(boost::bind(peekerWorker, accepted, false));
+  shared_ptr<TTransport> accepted = sock1.accept();
+  static_pointer_cast<TSSLSocket>(accepted)->setRecvTimeout(1000);
+  boost::thread peekThread(apache::thrift::stdcxx::bind(peekerWorker, accepted, false));
   clientSock->write((const uint8_t*)"0", 1);
   boost::this_thread::sleep(boost::posix_time::milliseconds(50));
   // peekThread is practically guaranteed to be blocking now