diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index 5ff5e44..585f89a 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -31,7 +31,6 @@
 #include <thrift/transport/TTransportUtils.h>
 #include <thrift/transport/TFileTransport.h>
 #include <thrift/TLogging.h>
-#include <thrift/stdcxx.h>
 
 #include "Service.h"
 #include <iostream>
@@ -108,8 +107,8 @@
 };
 class ClientThread : public Runnable {
 public:
-  ClientThread(stdcxx::shared_ptr<TTransport> transport,
-               stdcxx::shared_ptr<ServiceIf> client,
+  ClientThread(std::shared_ptr<TTransport> transport,
+               std::shared_ptr<ServiceIf> client,
                Monitor& monitor,
                size_t& workerCount,
                size_t loopCount,
@@ -225,8 +224,8 @@
     }
   }
 
-  stdcxx::shared_ptr<TTransport> _transport;
-  stdcxx::shared_ptr<ServiceIf> _client;
+  std::shared_ptr<TTransport> _transport;
+  std::shared_ptr<ServiceIf> _client;
   Monitor& _monitor;
   size_t& _workerCount;
   size_t _loopCount;
@@ -391,24 +390,24 @@
     cerr << usage.str();
   }
 
-  stdcxx::shared_ptr<PlatformThreadFactory> threadFactory
-      = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  std::shared_ptr<PlatformThreadFactory> threadFactory
+      = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
-  stdcxx::shared_ptr<Server> serviceHandler(new Server());
+  std::shared_ptr<Server> serviceHandler(new Server());
 
   if (replayRequests) {
-    stdcxx::shared_ptr<Server> serviceHandler(new Server());
-    stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
+    std::shared_ptr<Server> serviceHandler(new Server());
+    std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
 
     // Transports
-    stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
+    std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
     fileTransport->setChunkSize(2 * 1024 * 1024);
     fileTransport->setMaxEventSize(1024 * 16);
     fileTransport->seekToEnd();
 
     // Protocol Factory
-    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
 
@@ -418,28 +417,28 @@
 
   if (runServer) {
 
-    stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
+    std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
 
     // Transport
-    stdcxx::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
+    std::shared_ptr<TServerSocket> serverSocket(new TServerSocket(port));
 
     // Transport Factory
-    stdcxx::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
+    std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
 
     // Protocol Factory
-    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     if (logRequests) {
       // initialize the log file
-      stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
+      std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
       transportFactory
-          = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+          = std::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
-    stdcxx::shared_ptr<TServer> server;
+    std::shared_ptr<TServer> server;
 
     if (serverType == "simple") {
 
@@ -453,7 +452,7 @@
 
     } else if (serverType == "thread-pool") {
 
-      stdcxx::shared_ptr<ThreadManager> threadManager
+      std::shared_ptr<ThreadManager> threadManager
           = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
@@ -465,9 +464,9 @@
                                          threadManager));
     }
 
-    stdcxx::shared_ptr<TStartObserver> observer(new TStartObserver);
+    std::shared_ptr<TStartObserver> observer(new TStartObserver);
     server->setServerEventHandler(observer);
-    stdcxx::shared_ptr<Thread> serverThread = threadFactory->newThread(server);
+    std::shared_ptr<Thread> serverThread = threadFactory->newThread(server);
 
     cerr << "Starting the server on port " << port << endl;
 
@@ -486,7 +485,7 @@
 
     size_t threadCount = 0;
 
-    set<stdcxx::shared_ptr<Thread> > clientThreads;
+    set<std::shared_ptr<Thread> > clientThreads;
 
     if (callName == "echoVoid") {
       loopType = T_VOID;
@@ -505,28 +504,28 @@
     if(clientType == "regular") {
       for (size_t ix = 0; ix < clientCount; ix++) {
 
-        stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
-        stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
-        stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
-        stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
+        std::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
+        std::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
+        std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
+        std::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-        clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>(
+        clientThreads.insert(threadFactory->newThread(std::shared_ptr<ClientThread>(
             new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, OpenAndCloseTransportInThread))));
       }
     } else if(clientType == "concurrent") {
-      stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
-      stdcxx::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
-      stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
-      //stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
-      stdcxx::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol));
+      std::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port));
+      std::shared_ptr<TBufferedTransport> bufferedSocket(new TBufferedTransport(socket, 2048));
+      std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(bufferedSocket));
+      //std::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
+      std::shared_ptr<ServiceConcurrentClient> serviceClient(new ServiceConcurrentClient(protocol));
       socket->open();
       for (size_t ix = 0; ix < clientCount; ix++) {
-        clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>(
+        clientThreads.insert(threadFactory->newThread(std::shared_ptr<ClientThread>(
             new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType, DontOpenAndCloseTransportInThread))));
       }
     }
 
-    for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+    for (std::set<std::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
          thread != clientThreads.end();
          thread++) {
       (*thread)->start();
@@ -559,12 +558,12 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+    for (set<std::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
          ix != clientThreads.end();
          ix++) {
 
-      stdcxx::shared_ptr<ClientThread> client
-          = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      std::shared_ptr<ClientThread> client
+          = std::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index e68988f..1d3ed73 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -33,7 +33,6 @@
 #include <thrift/transport/TTransportUtils.h>
 #include <thrift/transport/TFileTransport.h>
 #include <thrift/TLogging.h>
-#include <thrift/stdcxx.h>
 
 #include "Service.h"
 
@@ -109,8 +108,8 @@
 
 class ClientThread : public Runnable {
 public:
-  ClientThread(stdcxx::shared_ptr<TTransport> transport,
-               stdcxx::shared_ptr<ServiceClient> client,
+  ClientThread(std::shared_ptr<TTransport> transport,
+               std::shared_ptr<ServiceClient> client,
                Monitor& monitor,
                size_t& workerCount,
                size_t loopCount,
@@ -221,8 +220,8 @@
     }
   }
 
-  stdcxx::shared_ptr<TTransport> _transport;
-  stdcxx::shared_ptr<ServiceClient> _client;
+  std::shared_ptr<TTransport> _transport;
+  std::shared_ptr<ServiceClient> _client;
   Monitor& _monitor;
   size_t& _workerCount;
   size_t _loopCount;
@@ -344,24 +343,24 @@
     cerr << usage.str();
   }
 
-  stdcxx::shared_ptr<PlatformThreadFactory> threadFactory
-      = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+  std::shared_ptr<PlatformThreadFactory> threadFactory
+      = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
   // Dispatcher
-  stdcxx::shared_ptr<Server> serviceHandler(new Server());
+  std::shared_ptr<Server> serviceHandler(new Server());
 
   if (replayRequests) {
-    stdcxx::shared_ptr<Server> serviceHandler(new Server());
-    stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
+    std::shared_ptr<Server> serviceHandler(new Server());
+    std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
 
     // Transports
-    stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
+    std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
     fileTransport->setChunkSize(2 * 1024 * 1024);
     fileTransport->setMaxEventSize(1024 * 16);
     fileTransport->seekToEnd();
 
     // Protocol Factory
-    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     TFileProcessor fileProcessor(serviceProcessor, protocolFactory, fileTransport);
 
@@ -371,50 +370,50 @@
 
   if (runServer) {
 
-    stdcxx::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
+    std::shared_ptr<ServiceProcessor> serviceProcessor(new ServiceProcessor(serviceHandler));
 
     // Protocol Factory
-    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
     // Transport Factory
-    stdcxx::shared_ptr<TTransportFactory> transportFactory;
+    std::shared_ptr<TTransportFactory> transportFactory;
 
     if (logRequests) {
       // initialize the log file
-      stdcxx::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
+      std::shared_ptr<TFileTransport> fileTransport(new TFileTransport(requestLogPath));
       fileTransport->setChunkSize(2 * 1024 * 1024);
       fileTransport->setMaxEventSize(1024 * 16);
 
       transportFactory
-          = stdcxx::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
+          = std::shared_ptr<TTransportFactory>(new TPipedTransportFactory(fileTransport));
     }
 
-    stdcxx::shared_ptr<Thread> serverThread;
-    stdcxx::shared_ptr<Thread> serverThread2;
-    stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket1;
-    stdcxx::shared_ptr<transport::TNonblockingServerSocket> nbSocket2;
+    std::shared_ptr<Thread> serverThread;
+    std::shared_ptr<Thread> serverThread2;
+    std::shared_ptr<transport::TNonblockingServerSocket> nbSocket1;
+    std::shared_ptr<transport::TNonblockingServerSocket> nbSocket2;
 
     if (serverType == "simple") {
 
       nbSocket1.reset(new transport::TNonblockingServerSocket(port));
-      serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
+      serverThread = threadFactory->newThread(std::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1)));
       nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1));
-      serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
+      serverThread2 = threadFactory->newThread(std::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2)));
 
     } else if (serverType == "thread-pool") {
 
-      stdcxx::shared_ptr<ThreadManager> threadManager
+      std::shared_ptr<ThreadManager> threadManager
           = ThreadManager::newSimpleThreadManager(workerCount);
 
       threadManager->threadFactory(threadFactory);
       threadManager->start();
       nbSocket1.reset(new transport::TNonblockingServerSocket(port));
-      serverThread = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
+      serverThread = threadFactory->newThread(std::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket1, threadManager)));
       nbSocket2.reset(new transport::TNonblockingServerSocket(port + 1));
-      serverThread2 = threadFactory->newThread(stdcxx::shared_ptr<TServer>(
+      serverThread2 = threadFactory->newThread(std::shared_ptr<TServer>(
           new TNonblockingServer(serviceProcessor, protocolFactory, nbSocket2, threadManager)));
     }
 
@@ -437,7 +436,7 @@
 
     size_t threadCount = 0;
 
-    set<stdcxx::shared_ptr<Thread> > clientThreads;
+    set<std::shared_ptr<Thread> > clientThreads;
 
     if (callName == "echoVoid") {
       loopType = T_VOID;
@@ -455,16 +454,16 @@
 
     for (uint32_t ix = 0; ix < clientCount; ix++) {
 
-      stdcxx::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2)));
-      stdcxx::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
-      stdcxx::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
-      stdcxx::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
+      std::shared_ptr<TSocket> socket(new TSocket("127.0.0.1", port + (ix % 2)));
+      std::shared_ptr<TFramedTransport> framedSocket(new TFramedTransport(socket));
+      std::shared_ptr<TProtocol> protocol(new TBinaryProtocol(framedSocket));
+      std::shared_ptr<ServiceClient> serviceClient(new ServiceClient(protocol));
 
-      clientThreads.insert(threadFactory->newThread(stdcxx::shared_ptr<ClientThread>(
+      clientThreads.insert(threadFactory->newThread(std::shared_ptr<ClientThread>(
           new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<stdcxx::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+    for (std::set<std::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
          thread != clientThreads.end();
          thread++) {
       (*thread)->start();
@@ -497,12 +496,12 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<stdcxx::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+    for (set<std::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
          ix != clientThreads.end();
          ix++) {
 
-      stdcxx::shared_ptr<ClientThread> client
-          = stdcxx::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
+      std::shared_ptr<ClientThread> client
+          = std::dynamic_pointer_cast<ClientThread>((*ix)->runnable());
 
       int64_t delta = client->_endTime - client->_startTime;
 
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index ca21326..89f3fd1 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -46,7 +46,6 @@
 #include <boost/filesystem.hpp>
 #include <boost/program_options.hpp>
 #include <boost/random/random_device.hpp>
-#include <thrift/stdcxx.h>
 #if _WIN32
 #include <thrift/windows/TWinsockSingleton.h>
 #endif
@@ -98,10 +97,10 @@
     for (int testNr = 0; testNr < 10; ++testNr) {
       std::ostringstream os;
       os << "test" << testNr;
-      client->testString(stdcxx::bind(testString_clientReturn,
+      client->testString(std::bind(testString_clientReturn,
                                     base,
                                     testNr,
-                                    stdcxx::placeholders::_1),
+                                    std::placeholders::_1),
                        os.str());
     }
   } catch (TException& exn) {
@@ -254,18 +253,18 @@
   }
 
   // THRIFT-4164: The factory MUST outlive any sockets it creates for correct behavior!
-  stdcxx::shared_ptr<TSSLSocketFactory> factory;
-  stdcxx::shared_ptr<TSocket> socket;
-  stdcxx::shared_ptr<TTransport> transport;
-  stdcxx::shared_ptr<TProtocol> protocol;
-  stdcxx::shared_ptr<TProtocol> protocol2;  // SecondService for multiplexed
+  std::shared_ptr<TSSLSocketFactory> factory;
+  std::shared_ptr<TSocket> socket;
+  std::shared_ptr<TTransport> transport;
+  std::shared_ptr<TProtocol> protocol;
+  std::shared_ptr<TProtocol> protocol2;  // SecondService for multiplexed
 
   if (ssl) {
     cout << "Client Certificate File: " << certPath << endl;
     cout << "Client Key         File: " << keyPath << endl;
     cout << "CA                 File: " << caPath << endl;
 
-    factory = stdcxx::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
+    factory = std::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
     factory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
     factory->loadTrustedCertificates(caPath.c_str());
     factory->loadCertificate(certPath.c_str());
@@ -277,42 +276,42 @@
       if (abstract_namespace) {
         std::string abstract_socket("\0", 1);
         abstract_socket += domain_socket;
-        socket = stdcxx::shared_ptr<TSocket>(new TSocket(abstract_socket));
+        socket = std::shared_ptr<TSocket>(new TSocket(abstract_socket));
       } else {
-        socket = stdcxx::shared_ptr<TSocket>(new TSocket(domain_socket));
+        socket = std::shared_ptr<TSocket>(new TSocket(domain_socket));
       }
       port = 0;
     } else {
-      socket = stdcxx::shared_ptr<TSocket>(new TSocket(host, port));
+      socket = std::shared_ptr<TSocket>(new TSocket(host, port));
     }
   }
 
   if (transport_type.compare("http") == 0) {
-    transport = stdcxx::make_shared<THttpClient>(socket, host, "/service");
+    transport = std::make_shared<THttpClient>(socket, host, "/service");
   } else if (transport_type.compare("framed") == 0) {
-    transport = stdcxx::make_shared<TFramedTransport>(socket);
+    transport = std::make_shared<TFramedTransport>(socket);
   } else {
-    transport = stdcxx::make_shared<TBufferedTransport>(socket);
+    transport = std::make_shared<TBufferedTransport>(socket);
   }
 
   if (zlib) {
-    transport = stdcxx::make_shared<TZlibTransport>(transport);
+    transport = std::make_shared<TZlibTransport>(transport);
   }
 
   if (protocol_type == "json" || protocol_type == "multij") {
-    protocol = stdcxx::make_shared<TJSONProtocol>(transport);
+    protocol = std::make_shared<TJSONProtocol>(transport);
   } else if (protocol_type == "compact" || protocol_type == "multic") {
-    protocol = stdcxx::make_shared<TCompactProtocol>(transport);
+    protocol = std::make_shared<TCompactProtocol>(transport);
   } else if (protocol_type == "header" || protocol_type == "multih") {
-    protocol = stdcxx::make_shared<THeaderProtocol>(transport);
+    protocol = std::make_shared<THeaderProtocol>(transport);
   } else {
-    protocol = stdcxx::make_shared<TBinaryProtocol>(transport);
+    protocol = std::make_shared<TBinaryProtocol>(transport);
   }
 
   if (boost::starts_with(protocol_type, "multi")) {
-  protocol2 = stdcxx::make_shared<TMultiplexedProtocol>(protocol, "SecondService");
+  protocol2 = std::make_shared<TMultiplexedProtocol>(protocol, "SecondService");
   // we don't need access to the original protocol any more, so...
-  protocol = stdcxx::make_shared<TMultiplexedProtocol>(protocol, "ThriftTest");
+  protocol = std::make_shared<TMultiplexedProtocol>(protocol, "ThriftTest");
   }
 
   // Connection info
@@ -334,14 +333,14 @@
     cout << "Libevent Features: 0x" << hex << event_base_get_features(base) << endl;
 #endif
 
-    stdcxx::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
+    std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
 
-    stdcxx::shared_ptr<TAsyncChannel> channel(
+    std::shared_ptr<TAsyncChannel> channel(
         new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base));
     ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get());
-    client->testVoid(stdcxx::bind(testVoid_clientReturn,
+    client->testVoid(std::bind(testVoid_clientReturn,
                                 base,
-                                stdcxx::placeholders::_1));
+                                std::placeholders::_1));
 
     event_base_loop(base, 0);
     return 0;
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 323f873..6222017 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -61,7 +61,6 @@
 #include <boost/algorithm/string.hpp>
 #include <boost/program_options.hpp>
 #include <boost/filesystem.hpp>
-#include <thrift/stdcxx.h>
 
 #if _WIN32
 #include <thrift/windows/TWinsockSingleton.h>
@@ -395,66 +394,66 @@
 
 class TestHandlerAsync : public ThriftTestCobSvIf {
 public:
-  TestHandlerAsync(stdcxx::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
+  TestHandlerAsync(std::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
   virtual ~TestHandlerAsync() {}
 
-  virtual void testVoid(stdcxx::function<void()> cob) {
+  virtual void testVoid(std::function<void()> cob) {
     _delegate->testVoid();
     cob();
   }
 
-  virtual void testString(stdcxx::function<void(std::string const& _return)> cob,
+  virtual void testString(std::function<void(std::string const& _return)> cob,
                           const std::string& thing) {
     std::string res;
     _delegate->testString(res, thing);
     cob(res);
   }
 
-  virtual void testBool(stdcxx::function<void(bool const& _return)> cob, const bool thing) {
+  virtual void testBool(std::function<void(bool const& _return)> cob, const bool thing) {
     bool res = _delegate->testBool(thing);
     cob(res);
   }
 
-  virtual void testByte(stdcxx::function<void(int8_t const& _return)> cob, const int8_t thing) {
+  virtual void testByte(std::function<void(int8_t const& _return)> cob, const int8_t thing) {
     int8_t res = _delegate->testByte(thing);
     cob(res);
   }
 
-  virtual void testI32(stdcxx::function<void(int32_t const& _return)> cob, const int32_t thing) {
+  virtual void testI32(std::function<void(int32_t const& _return)> cob, const int32_t thing) {
     int32_t res = _delegate->testI32(thing);
     cob(res);
   }
 
-  virtual void testI64(stdcxx::function<void(int64_t const& _return)> cob, const int64_t thing) {
+  virtual void testI64(std::function<void(int64_t const& _return)> cob, const int64_t thing) {
     int64_t res = _delegate->testI64(thing);
     cob(res);
   }
 
-  virtual void testDouble(stdcxx::function<void(double const& _return)> cob, const double thing) {
+  virtual void testDouble(std::function<void(double const& _return)> cob, const double thing) {
     double res = _delegate->testDouble(thing);
     cob(res);
   }
 
-  virtual void testBinary(stdcxx::function<void(std::string const& _return)> cob,
+  virtual void testBinary(std::function<void(std::string const& _return)> cob,
                           const std::string& thing) {
     std::string res;
     _delegate->testBinary(res, thing);
     cob(res);
   }
 
-  virtual void testStruct(stdcxx::function<void(Xtruct const& _return)> cob, const Xtruct& thing) {
+  virtual void testStruct(std::function<void(Xtruct const& _return)> cob, const Xtruct& thing) {
     Xtruct res;
     _delegate->testStruct(res, thing);
     cob(res);
   }
 
-  virtual void testNest(stdcxx::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) {
+  virtual void testNest(std::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) {
     Xtruct2 res;
     _delegate->testNest(res, thing);
     cob(res);
   }
 
-  virtual void testMap(stdcxx::function<void(std::map<int32_t, int32_t> const& _return)> cob,
+  virtual void testMap(std::function<void(std::map<int32_t, int32_t> const& _return)> cob,
                        const std::map<int32_t, int32_t>& thing) {
     std::map<int32_t, int32_t> res;
     _delegate->testMap(res, thing);
@@ -462,40 +461,40 @@
   }
 
   virtual void testStringMap(
-      stdcxx::function<void(std::map<std::string, std::string> const& _return)> cob,
+      std::function<void(std::map<std::string, std::string> const& _return)> cob,
       const std::map<std::string, std::string>& thing) {
     std::map<std::string, std::string> res;
     _delegate->testStringMap(res, thing);
     cob(res);
   }
 
-  virtual void testSet(stdcxx::function<void(std::set<int32_t> const& _return)> cob,
+  virtual void testSet(std::function<void(std::set<int32_t> const& _return)> cob,
                        const std::set<int32_t>& thing) {
     std::set<int32_t> res;
     _delegate->testSet(res, thing);
     cob(res);
   }
 
-  virtual void testList(stdcxx::function<void(std::vector<int32_t> const& _return)> cob,
+  virtual void testList(std::function<void(std::vector<int32_t> const& _return)> cob,
                         const std::vector<int32_t>& thing) {
     std::vector<int32_t> res;
     _delegate->testList(res, thing);
     cob(res);
   }
 
-  virtual void testEnum(stdcxx::function<void(Numberz::type const& _return)> cob,
+  virtual void testEnum(std::function<void(Numberz::type const& _return)> cob,
                         const Numberz::type thing) {
     Numberz::type res = _delegate->testEnum(thing);
     cob(res);
   }
 
-  virtual void testTypedef(stdcxx::function<void(UserId const& _return)> cob, const UserId thing) {
+  virtual void testTypedef(std::function<void(UserId const& _return)> cob, const UserId thing) {
     UserId res = _delegate->testTypedef(thing);
     cob(res);
   }
 
   virtual void testMapMap(
-      stdcxx::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
+      std::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
       const int32_t hello) {
     std::map<int32_t, std::map<int32_t, int32_t> > res;
     _delegate->testMapMap(res, hello);
@@ -503,14 +502,14 @@
   }
 
   virtual void testInsanity(
-      stdcxx::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
+      std::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
       const Insanity& argument) {
     std::map<UserId, std::map<Numberz::type, Insanity> > res;
     _delegate->testInsanity(res, argument);
     cob(res);
   }
 
-  virtual void testMulti(stdcxx::function<void(Xtruct const& _return)> cob,
+  virtual void testMulti(std::function<void(Xtruct const& _return)> cob,
                          const int8_t arg0,
                          const int32_t arg1,
                          const int64_t arg2,
@@ -523,8 +522,8 @@
   }
 
   virtual void testException(
-      stdcxx::function<void()> cob,
-      stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
+      std::function<void()> cob,
+      std::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
       const std::string& arg) {
     try {
       _delegate->testException(arg);
@@ -536,8 +535,8 @@
   }
 
   virtual void testMultiException(
-      stdcxx::function<void(Xtruct const& _return)> cob,
-      stdcxx::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
+      std::function<void(Xtruct const& _return)> cob,
+      std::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
       const std::string& arg0,
       const std::string& arg1) {
     Xtruct res;
@@ -550,13 +549,13 @@
     cob(res);
   }
 
-  virtual void testOneway(stdcxx::function<void()> cob, const int32_t secondsToSleep) {
+  virtual void testOneway(std::function<void()> cob, const int32_t secondsToSleep) {
     _delegate->testOneway(secondsToSleep);
     cob();
   }
 
 protected:
-  stdcxx::shared_ptr<TestHandler> _delegate;
+  std::shared_ptr<TestHandler> _delegate;
 };
 
 namespace po = boost::program_options;
@@ -668,9 +667,9 @@
   }
 
   // Dispatcher
-  stdcxx::shared_ptr<TProtocolFactory> protocolFactory;
+  std::shared_ptr<TProtocolFactory> protocolFactory;
   if (protocol_type == "json" || protocol_type == "multij") {
-    stdcxx::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory());
+    std::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory());
     protocolFactory = jsonProtocolFactory;
   } else if (protocol_type == "compact" || protocol_type == "multic") {
     TCompactProtocolFactoryT<TBufferBase> *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>();
@@ -678,7 +677,7 @@
     compactProtocolFactory->setStringSizeLimit(string_limit);
     protocolFactory.reset(compactProtocolFactory);
   } else if (protocol_type == "header" || protocol_type == "multih") {
-    stdcxx::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory());
+    std::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory());
     protocolFactory = headerProtocolFactory;
   } else {
     TBinaryProtocolFactoryT<TBufferBase>* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>();
@@ -688,56 +687,56 @@
   }
 
   // Processors
-  stdcxx::shared_ptr<TestHandler> testHandler(new TestHandler());
-  stdcxx::shared_ptr<TProcessor> testProcessor(new ThriftTestProcessor(testHandler));
+  std::shared_ptr<TestHandler> testHandler(new TestHandler());
+  std::shared_ptr<TProcessor> testProcessor(new ThriftTestProcessor(testHandler));
 
   if (vm.count("processor-events")) {
     testProcessor->setEventHandler(
-        stdcxx::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
+        std::shared_ptr<TProcessorEventHandler>(new TestProcessorEventHandler()));
   }
 
   // Transport
-  stdcxx::shared_ptr<TSSLSocketFactory> sslSocketFactory;
-  stdcxx::shared_ptr<TServerSocket> serverSocket;
+  std::shared_ptr<TSSLSocketFactory> sslSocketFactory;
+  std::shared_ptr<TServerSocket> serverSocket;
 
   if (ssl) {
-    sslSocketFactory = stdcxx::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
+    sslSocketFactory = std::shared_ptr<TSSLSocketFactory>(new TSSLSocketFactory());
     sslSocketFactory->loadCertificate(certPath.c_str());
     sslSocketFactory->loadPrivateKey(keyPath.c_str());
     sslSocketFactory->ciphers("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
     if (server_type != "nonblocking") {
-      serverSocket = stdcxx::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory));
+      serverSocket = std::shared_ptr<TServerSocket>(new TSSLServerSocket(port, sslSocketFactory));
     }
   } else {
     if (domain_socket != "") {
       if (abstract_namespace) {
         std::string abstract_socket("\0", 1);
         abstract_socket += domain_socket;
-        serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket));
+        serverSocket = std::shared_ptr<TServerSocket>(new TServerSocket(abstract_socket));
       } else {
         unlink(domain_socket.c_str());
-        serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(domain_socket));
+        serverSocket = std::shared_ptr<TServerSocket>(new TServerSocket(domain_socket));
       }
       port = 0;
     } else {
-      serverSocket = stdcxx::shared_ptr<TServerSocket>(new TServerSocket(port));
+      serverSocket = std::shared_ptr<TServerSocket>(new TServerSocket(port));
     }
   }
 
   // Factory
-  stdcxx::shared_ptr<TTransportFactory> transportFactory;
+  std::shared_ptr<TTransportFactory> transportFactory;
 
   if (transport_type == "http" && server_type != "nonblocking") {
-    transportFactory = stdcxx::make_shared<THttpServerTransportFactory>();
+    transportFactory = std::make_shared<THttpServerTransportFactory>();
   } else if (transport_type == "framed") {
-    transportFactory = stdcxx::make_shared<TFramedTransportFactory>();
+    transportFactory = std::make_shared<TFramedTransportFactory>();
   } else {
-    transportFactory = stdcxx::make_shared<TBufferedTransportFactory>();
+    transportFactory = std::make_shared<TBufferedTransportFactory>();
   }
 
   if (zlib) {
     // hmm.. doesn't seem to be a way to make it wrap the others...
-    transportFactory = stdcxx::make_shared<TZlibTransportFactory>();
+    transportFactory = std::make_shared<TZlibTransportFactory>();
   }
 
   // Server Info
@@ -754,27 +753,27 @@
 
   // Multiplexed Processor if needed
   if (boost::starts_with(protocol_type, "multi")) {
-    stdcxx::shared_ptr<SecondHandler> secondHandler(new SecondHandler());
-    stdcxx::shared_ptr<SecondServiceProcessor> secondProcessor(new SecondServiceProcessor(secondHandler));
+    std::shared_ptr<SecondHandler> secondHandler(new SecondHandler());
+    std::shared_ptr<SecondServiceProcessor> secondProcessor(new SecondServiceProcessor(secondHandler));
 
-    stdcxx::shared_ptr<TMultiplexedProcessor> multiplexedProcessor(new TMultiplexedProcessor());
+    std::shared_ptr<TMultiplexedProcessor> multiplexedProcessor(new TMultiplexedProcessor());
     multiplexedProcessor->registerDefault(testProcessor); // non-multi clients go to the default processor (multi:binary, multic:compact, ...)
     multiplexedProcessor->registerProcessor("ThriftTest", testProcessor);
     multiplexedProcessor->registerProcessor("SecondService", secondProcessor);
-    testProcessor = stdcxx::dynamic_pointer_cast<TProcessor>(multiplexedProcessor);
+    testProcessor = std::dynamic_pointer_cast<TProcessor>(multiplexedProcessor);
   }
 
   // Server
-  stdcxx::shared_ptr<apache::thrift::server::TServer> server;
+  std::shared_ptr<apache::thrift::server::TServer> server;
 
   if (server_type == "simple") {
     server.reset(new TSimpleServer(testProcessor, serverSocket, transportFactory, protocolFactory));
   } else if (server_type == "thread-pool") {
 
-    stdcxx::shared_ptr<PlatformThreadFactory> threadFactory
-        = stdcxx::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
+    std::shared_ptr<PlatformThreadFactory> threadFactory
+        = std::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
 
-    stdcxx::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
+    std::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(workers);
     threadManager->threadFactory(threadFactory);
     threadManager->start();
 
@@ -788,10 +787,10 @@
         new TThreadedServer(testProcessor, serverSocket, transportFactory, protocolFactory));
   } else if (server_type == "nonblocking") {
     if (transport_type == "http") {
-      stdcxx::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
-      stdcxx::shared_ptr<TAsyncProcessor> testProcessorAsync(
+      std::shared_ptr<TestHandlerAsync> testHandlerAsync(new TestHandlerAsync(testHandler));
+      std::shared_ptr<TAsyncProcessor> testProcessorAsync(
           new ThriftTestAsyncProcessor(testHandlerAsync));
-      stdcxx::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
+      std::shared_ptr<TAsyncBufferProcessor> testBufferProcessor(
           new TAsyncProtocolProcessor(testProcessorAsync, protocolFactory));
 
       // not loading nonblockingServer into "server" because
@@ -800,7 +799,7 @@
       TEvhttpServer nonblockingServer(testBufferProcessor, port);
       nonblockingServer.serve();
     } else if (transport_type == "framed") {
-      stdcxx::shared_ptr<transport::TNonblockingServerTransport> nbSocket;
+      std::shared_ptr<transport::TNonblockingServerTransport> nbSocket;
       nbSocket.reset(
           ssl ? new transport::TNonblockingSSLServerSocket(port, sslSocketFactory)
               : new transport::TNonblockingServerSocket(port));
@@ -815,13 +814,13 @@
     if (protocol_type == "header") {
       // Tell the server to use the same protocol for input / output
       // if using header
-      server->setOutputProtocolFactory(stdcxx::shared_ptr<TProtocolFactory>());
+      server->setOutputProtocolFactory(std::shared_ptr<TProtocolFactory>());
     }
     
     apache::thrift::concurrency::PlatformThreadFactory factory;
     factory.setDetached(false);
-    stdcxx::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
-    stdcxx::shared_ptr<apache::thrift::concurrency::Thread> thread
+    std::shared_ptr<apache::thrift::concurrency::Runnable> serverThreadRunner(server);
+    std::shared_ptr<apache::thrift::concurrency::Thread> thread
         = factory.newThread(serverThreadRunner);
 
 #ifdef HAVE_SIGNAL_H
