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/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
index ccef9d5..d6ab457 100644
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -26,7 +26,7 @@
 #endif
 #include <sstream>
 #include <fstream>
-#include <thrift/cxxfunctional.h>
+#include <thrift/stdcxx.h>
 
 #include <boost/mpl/list.hpp>
 #include <boost/shared_array.hpp>
@@ -43,10 +43,12 @@
 
 #include <thrift/concurrency/FunctionRunner.h>
 #if _WIN32
+#include <thrift/transport/TPipe.h>
 #include <thrift/windows/TWinsockSingleton.h>
 #endif
 
 using namespace apache::thrift::transport;
+using namespace apache::thrift;
 
 static boost::mt19937 rng;
 
@@ -112,7 +114,7 @@
   std::string describe() const { return generator_->describe(); }
 
 private:
-  boost::shared_ptr<SizeGenerator> generator_;
+  stdcxx::shared_ptr<SizeGenerator> generator_;
 };
 
 /**************************************************************************
@@ -135,8 +137,8 @@
 
   CoupledTransports() : in(), out() {}
 
-  boost::shared_ptr<Transport_> in;
-  boost::shared_ptr<Transport_> out;
+  stdcxx::shared_ptr<Transport_> in;
+  stdcxx::shared_ptr<Transport_> out;
 
 private:
   CoupledTransports(const CoupledTransports&);
@@ -153,7 +155,7 @@
     out = buf;
   }
 
-  boost::shared_ptr<TMemoryBuffer> buf;
+  stdcxx::shared_ptr<TMemoryBuffer> buf;
 };
 
 /**
@@ -219,6 +221,22 @@
     out.reset(new TFDTransport(pipes[1], TFDTransport::CLOSE_ON_DESTROY));
   }
 };
+#else
+/**
+ * Coupled pipe transports
+ */
+class CoupledPipeTransports : public CoupledTransports<TPipe> {
+public:
+  HANDLE hRead;
+  HANDLE hWrite;
+
+  CoupledPipeTransports() {
+    BOOST_REQUIRE(CreatePipe(&hRead, &hWrite, NULL, 1048576 * 2));
+    in.reset(new TPipe(hRead, hWrite));
+    in->open();
+    out = in;
+  }
+};
 #endif
 
 /**
@@ -323,11 +341,11 @@
  **************************************************************************/
 
 struct TriggerInfo {
-  TriggerInfo(int seconds, const boost::shared_ptr<TTransport>& transport, uint32_t writeLength)
+  TriggerInfo(int seconds, const stdcxx::shared_ptr<TTransport>& transport, uint32_t writeLength)
     : timeoutSeconds(seconds), transport(transport), writeLength(writeLength), next(NULL) {}
 
   int timeoutSeconds;
-  boost::shared_ptr<TTransport> transport;
+  stdcxx::shared_ptr<TTransport> transport;
   uint32_t writeLength;
   TriggerInfo* next;
 };
@@ -402,7 +420,7 @@
  * to the end.)
  */
 void add_trigger(unsigned int seconds,
-                 const boost::shared_ptr<TTransport>& transport,
+                 const stdcxx::shared_ptr<TTransport>& transport,
                  uint32_t write_len) {
   TriggerInfo* info = new TriggerInfo(seconds, transport, write_len);
   {
@@ -442,7 +460,7 @@
 }
 
 void set_trigger(unsigned int seconds,
-                 const boost::shared_ptr<TTransport>& transport,
+                 const stdcxx::shared_ptr<TTransport>& transport,
                  uint32_t write_len) {
   clear_triggers();
   add_trigger(seconds, transport, write_len);
@@ -840,6 +858,19 @@
     TEST_RW(CoupledFDTransports, 1024 * 16, 1, 1, rand4k, rand4k, fd_max_outstanding);
 
     TEST_BLOCKING_BEHAVIOR(CoupledFDTransports);
+#else
+    // TPipe tests (WIN32 only)
+    TEST_RW(CoupledPipeTransports, 1024 * 1024, 0, 0);
+    TEST_RW(CoupledPipeTransports, 1024 * 256, rand4k, rand4k);
+    TEST_RW(CoupledPipeTransports, 1024 * 256, 167, 163);
+    TEST_RW(CoupledPipeTransports, 1024 * 16, 1, 1);
+
+    TEST_RW(CoupledPipeTransports, 1024 * 256, 0, 0, rand4k, rand4k);
+    TEST_RW(CoupledPipeTransports, 1024 * 256, rand4k, rand4k, rand4k, rand4k);
+    TEST_RW(CoupledPipeTransports, 1024 * 256, 167, 163, rand4k, rand4k);
+    TEST_RW(CoupledPipeTransports, 1024 * 16, 1, 1, rand4k, rand4k);
+
+    TEST_BLOCKING_BEHAVIOR(CoupledPipeTransports);
 #endif //_WIN32
 
     // TSocket tests
@@ -945,11 +976,11 @@
          << rChunkSizeGen.describe() << ", " << maxOutstanding << ")";
 
 #if (BOOST_VERSION >= 105900)
-    boost::function<void ()> test_func
+    stdcxx::function<void ()> test_func
 #else
     boost::unit_test::callback0<> test_func
 #endif
-        = apache::thrift::stdcxx::bind(test_rw<CoupledTransports>,
+        = stdcxx::bind(test_rw<CoupledTransports>,
                                        totalSize,
                                        wSizeGen,
                                        rSizeGen,
@@ -995,7 +1026,7 @@
  **************************************************************************/
 
 struct global_fixture {
-  boost::shared_ptr<apache::thrift::concurrency::Thread> alarmThread_;
+  stdcxx::shared_ptr<apache::thrift::concurrency::Thread> alarmThread_;
   global_fixture() {
 #if _WIN32
     apache::thrift::transport::TWinsockSingleton::create();