diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp
index 930261e..1683125 100644
--- a/test/cpp/src/StressTest.cpp
+++ b/test/cpp/src/StressTest.cpp
@@ -64,7 +64,7 @@
 
 class Server : public ServiceIf {
 public:
-  Server() {}
+  Server() = default;
 
   void count(const char* method) {
     Guard m(lock_);
@@ -72,7 +72,7 @@
     counts_[method] = ++ct;
   }
 
-  void echoVoid() {
+  void echoVoid() override {
     count("echoVoid");
     return;
   }
@@ -82,18 +82,18 @@
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) { return arg; }
-  int32_t echoI32(const int32_t arg) { return arg; }
-  int64_t echoI64(const int64_t arg) { return arg; }
-  void echoString(string& out, const string& arg) {
+  int8_t echoByte(const int8_t arg) override { return arg; }
+  int32_t echoI32(const int32_t arg) override { return arg; }
+  int64_t echoI64(const int64_t arg) override { return arg; }
+  void echoString(string& out, const string& arg) override {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
-  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
+  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) override { out = arg; }
+  void echoSet(set<int8_t>& out, const set<int8_t>& arg) override { out = arg; }
+  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) override { out = arg; }
 
 private:
   count_map counts_;
@@ -121,7 +121,7 @@
       _loopType(loopType),
       _behavior(behavior) {}
 
-  void run() {
+  void run() override {
 
     // Wait for all worker threads to start
 
@@ -239,7 +239,7 @@
 class TStartObserver : public apache::thrift::server::TServerEventHandler {
 public:
   TStartObserver() : awake_(false) {}
-  virtual void preServe() {
+  void preServe() override {
     apache::thrift::concurrency::Synchronized s(m_);
     awake_ = true;
     m_.notifyAll();
@@ -524,7 +524,7 @@
       }
     }
 
-    for (std::set<std::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+    for (auto thread = clientThreads.begin();
          thread != clientThreads.end();
          thread++) {
       (*thread)->start();
@@ -557,7 +557,7 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<std::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+    for (auto ix = clientThreads.begin();
          ix != clientThreads.end();
          ix++) {
 
diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp
index ead2df5..e94ecb2 100644
--- a/test/cpp/src/StressTestNonBlocking.cpp
+++ b/test/cpp/src/StressTestNonBlocking.cpp
@@ -67,7 +67,7 @@
 
 class Server : public ServiceIf {
 public:
-  Server() {}
+  Server() = default;
 
   void count(const char* method) {
     Guard m(lock_);
@@ -75,7 +75,7 @@
     counts_[method] = ++ct;
   }
 
-  void echoVoid() {
+  void echoVoid() override {
     count("echoVoid");
     // Sleep to simulate work
     THRIFT_SLEEP_USEC(1);
@@ -87,18 +87,18 @@
     return counts_;
   }
 
-  int8_t echoByte(const int8_t arg) { return arg; }
-  int32_t echoI32(const int32_t arg) { return arg; }
-  int64_t echoI64(const int64_t arg) { return arg; }
-  void echoString(string& out, const string& arg) {
+  int8_t echoByte(const int8_t arg) override { return arg; }
+  int32_t echoI32(const int32_t arg) override { return arg; }
+  int64_t echoI64(const int64_t arg) override { return arg; }
+  void echoString(string& out, const string& arg) override {
     if (arg != "hello") {
       T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str());
     }
     out = arg;
   }
-  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) { out = arg; }
-  void echoSet(set<int8_t>& out, const set<int8_t>& arg) { out = arg; }
-  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) { out = arg; }
+  void echoList(vector<int8_t>& out, const vector<int8_t>& arg) override { out = arg; }
+  void echoSet(set<int8_t>& out, const set<int8_t>& arg) override { out = arg; }
+  void echoMap(map<int8_t, int8_t>& out, const map<int8_t, int8_t>& arg) override { out = arg; }
 
 private:
   count_map counts_;
@@ -120,7 +120,7 @@
       _loopCount(loopCount),
       _loopType(loopType) {}
 
-  void run() {
+  void run() override {
 
     // Wait for all worker threads to start
 
@@ -462,7 +462,7 @@
           new ClientThread(socket, serviceClient, monitor, threadCount, loopCount, loopType))));
     }
 
-    for (std::set<std::shared_ptr<Thread> >::const_iterator thread = clientThreads.begin();
+    for (auto thread = clientThreads.begin();
          thread != clientThreads.end();
          thread++) {
       (*thread)->start();
@@ -495,7 +495,7 @@
     int64_t minTime = 9223372036854775807LL;
     int64_t maxTime = 0;
 
-    for (set<std::shared_ptr<Thread> >::iterator ix = clientThreads.begin();
+    for (auto ix = clientThreads.begin();
          ix != clientThreads.end();
          ix++) {
 
diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp
index 89f3fd1..2a06578 100644
--- a/test/cpp/src/TestClient.cpp
+++ b/test/cpp/src/TestClient.cpp
@@ -65,7 +65,7 @@
   int64_t ret;
   struct timeval tv;
 
-  THRIFT_GETTIMEOFDAY(&tv, NULL);
+  THRIFT_GETTIMEOFDAY(&tv, nullptr);
   ret = tv.tv_sec;
   ret = ret * 1000 * 1000 + tv.tv_usec;
   return ret;
@@ -942,11 +942,11 @@
       if (it1 == whoa.end()) {
         failed = true;
       } else {
-        map<Numberz::type, Insanity>::const_iterator it12 = it1->second.find(Numberz::TWO);
+        auto it12 = it1->second.find(Numberz::TWO);
         if (it12 == it1->second.end() || it12->second != insane) {
           failed = true;
         }
-        map<Numberz::type, Insanity>::const_iterator it13 = it1->second.find(Numberz::THREE);
+        auto it13 = it1->second.find(Numberz::THREE);
         if (it13 == it1->second.end() || it13->second != insane) {
           failed = true;
         }
@@ -955,7 +955,7 @@
       if (it2 == whoa.end()) {
         failed = true;
       } else {
-        map<Numberz::type, Insanity>::const_iterator it26 = it2->second.find(Numberz::SIX);
+        auto it26 = it2->second.find(Numberz::SIX);
         if (it26 == it2->second.end() || it26->second != Insanity()) {
           failed = true;
         }
diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp
index 4106628..8d5b4d9 100644
--- a/test/cpp/src/TestServer.cpp
+++ b/test/cpp/src/TestServer.cpp
@@ -90,48 +90,48 @@
 
 class TestHandler : public ThriftTestIf {
 public:
-  TestHandler() {}
+  TestHandler() = default;
 
-  void testVoid() { printf("testVoid()\n"); }
+  void testVoid() override { printf("testVoid()\n"); }
 
-  void testString(string& out, const string& thing) {
+  void testString(string& out, const string& thing) override {
     printf("testString(\"%s\")\n", thing.c_str());
     out = thing;
   }
 
-  bool testBool(const bool thing) {
+  bool testBool(const bool thing) override {
     printf("testBool(%s)\n", thing ? "true" : "false");
     return thing;
   }
 
-  int8_t testByte(const int8_t thing) {
+  int8_t testByte(const int8_t thing) override {
     printf("testByte(%d)\n", (int)thing);
     return thing;
   }
 
-  int32_t testI32(const int32_t thing) {
+  int32_t testI32(const int32_t thing) override {
     printf("testI32(%d)\n", thing);
     return thing;
   }
 
-  int64_t testI64(const int64_t thing) {
+  int64_t testI64(const int64_t thing) override {
     printf("testI64(%" PRId64 ")\n", thing);
     return thing;
   }
 
-  double testDouble(const double thing) {
+  double testDouble(const double thing) override {
     printf("testDouble(%f)\n", thing);
     return thing;
   }
 
-  void testBinary(std::string& _return, const std::string& thing) {
+  void testBinary(std::string& _return, const std::string& thing) override {
     std::ostringstream hexstr;
     hexstr << std::hex << thing;
     printf("testBinary(%lu: %s)\n", safe_numeric_cast<unsigned long>(thing.size()), hexstr.str().c_str());
     _return = thing;
   }
 
-  void testStruct(Xtruct& out, const Xtruct& thing) {
+  void testStruct(Xtruct& out, const Xtruct& thing) override {
     printf("testStruct({\"%s\", %d, %d, %" PRId64 "})\n",
            thing.string_thing.c_str(),
            (int)thing.byte_thing,
@@ -140,7 +140,7 @@
     out = thing;
   }
 
-  void testNest(Xtruct2& out, const Xtruct2& nest) {
+  void testNest(Xtruct2& out, const Xtruct2& nest) override {
     const Xtruct& thing = nest.struct_thing;
     printf("testNest({%d, {\"%s\", %d, %d, %" PRId64 "}, %d})\n",
            (int)nest.byte_thing,
@@ -152,7 +152,7 @@
     out = nest;
   }
 
-  void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) {
+  void testMap(map<int32_t, int32_t>& out, const map<int32_t, int32_t>& thing) override {
     printf("testMap({");
     map<int32_t, int32_t>::const_iterator m_iter;
     bool first = true;
@@ -169,7 +169,7 @@
   }
 
   void testStringMap(map<std::string, std::string>& out,
-                     const map<std::string, std::string>& thing) {
+                     const map<std::string, std::string>& thing) override {
     printf("testMap({");
     map<std::string, std::string>::const_iterator m_iter;
     bool first = true;
@@ -185,7 +185,7 @@
     out = thing;
   }
 
-  void testSet(set<int32_t>& out, const set<int32_t>& thing) {
+  void testSet(set<int32_t>& out, const set<int32_t>& thing) override {
     printf("testSet({");
     set<int32_t>::const_iterator s_iter;
     bool first = true;
@@ -201,7 +201,7 @@
     out = thing;
   }
 
-  void testList(vector<int32_t>& out, const vector<int32_t>& thing) {
+  void testList(vector<int32_t>& out, const vector<int32_t>& thing) override {
     printf("testList({");
     vector<int32_t>::const_iterator l_iter;
     bool first = true;
@@ -217,17 +217,17 @@
     out = thing;
   }
 
-  Numberz::type testEnum(const Numberz::type thing) {
+  Numberz::type testEnum(const Numberz::type thing) override {
     printf("testEnum(%d)\n", thing);
     return thing;
   }
 
-  UserId testTypedef(const UserId thing) {
+  UserId testTypedef(const UserId thing) override {
     printf("testTypedef(%" PRId64 ")\n", thing);
     return thing;
   }
 
-  void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) {
+  void testMapMap(map<int32_t, map<int32_t, int32_t> >& mapmap, const int32_t hello) override {
     printf("testMapMap(%d)\n", hello);
 
     map<int32_t, int32_t> pos;
@@ -241,7 +241,7 @@
     mapmap.insert(make_pair(-4, neg));
   }
 
-  void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) {
+  void testInsanity(map<UserId, map<Numberz::type, Insanity> >& insane, const Insanity& argument) override {
     printf("testInsanity()\n");
 
     Insanity looney;
@@ -297,7 +297,7 @@
                  const int64_t arg2,
                  const std::map<int16_t, std::string>& arg3,
                  const Numberz::type arg4,
-                 const UserId arg5) {
+                 const UserId arg5) override {
     (void)arg3;
     (void)arg4;
     (void)arg5;
@@ -310,7 +310,7 @@
     hello.i64_thing = (int64_t)arg2;
   }
 
-  void testException(const std::string& arg) {
+  void testException(const std::string& arg) override {
     printf("testException(%s)\n", arg.c_str());
     if (arg.compare("Xception") == 0) {
       Xception e;
@@ -329,7 +329,7 @@
 
   void testMultiException(Xtruct& result,
                           const std::string& arg0,
-                          const std::string& arg1) {
+                          const std::string& arg1) override {
 
     printf("testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
 
@@ -349,7 +349,7 @@
     }
   }
 
-  void testOneway(const int32_t aNum) {
+  void testOneway(const int32_t aNum) override {
     printf("testOneway(%d): call received\n", aNum);
   }
 };
@@ -357,33 +357,33 @@
 class SecondHandler : public SecondServiceIf
 {
   public:
-    void secondtestString(std::string& result, const std::string& thing)
+    void secondtestString(std::string& result, const std::string& thing) override
     { result = "testString(\"" + thing + "\")"; }
 };
 
 class TestProcessorEventHandler : public TProcessorEventHandler {
-  virtual void* getContext(const char* fn_name, void* serverContext) {
+  void* getContext(const char* fn_name, void* serverContext) override {
     (void)serverContext;
     return new std::string(fn_name);
   }
-  virtual void freeContext(void* ctx, const char* fn_name) {
+  void freeContext(void* ctx, const char* fn_name) override {
     (void)fn_name;
     delete static_cast<std::string*>(ctx);
   }
-  virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); }
-  virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) {
+  void preRead(void* ctx, const char* fn_name) override { communicate("preRead", ctx, fn_name); }
+  void postRead(void* ctx, const char* fn_name, uint32_t bytes) override {
     (void)bytes;
     communicate("postRead", ctx, fn_name);
   }
-  virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); }
-  virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) {
+  void preWrite(void* ctx, const char* fn_name) override { communicate("preWrite", ctx, fn_name); }
+  void postWrite(void* ctx, const char* fn_name, uint32_t bytes) override {
     (void)bytes;
     communicate("postWrite", ctx, fn_name);
   }
-  virtual void asyncComplete(void* ctx, const char* fn_name) {
+  void asyncComplete(void* ctx, const char* fn_name) override {
     communicate("asyncComplete", ctx, fn_name);
   }
-  virtual void handlerError(void* ctx, const char* fn_name) {
+  void handlerError(void* ctx, const char* fn_name) override {
     communicate("handlerError", ctx, fn_name);
   }
 
@@ -395,136 +395,136 @@
 class TestHandlerAsync : public ThriftTestCobSvIf {
 public:
   TestHandlerAsync(std::shared_ptr<TestHandler>& handler) : _delegate(handler) {}
-  virtual ~TestHandlerAsync() {}
+  ~TestHandlerAsync() override = default;
 
-  virtual void testVoid(std::function<void()> cob) {
+  void testVoid(std::function<void()> cob) override {
     _delegate->testVoid();
     cob();
   }
 
-  virtual void testString(std::function<void(std::string const& _return)> cob,
-                          const std::string& thing) {
+  void testString(std::function<void(std::string const& _return)> cob,
+                          const std::string& thing) override {
     std::string res;
     _delegate->testString(res, thing);
     cob(res);
   }
 
-  virtual void testBool(std::function<void(bool const& _return)> cob, const bool thing) {
+  void testBool(std::function<void(bool const& _return)> cob, const bool thing) override {
     bool res = _delegate->testBool(thing);
     cob(res);
   }
 
-  virtual void testByte(std::function<void(int8_t const& _return)> cob, const int8_t thing) {
+  void testByte(std::function<void(int8_t const& _return)> cob, const int8_t thing) override {
     int8_t res = _delegate->testByte(thing);
     cob(res);
   }
 
-  virtual void testI32(std::function<void(int32_t const& _return)> cob, const int32_t thing) {
+  void testI32(std::function<void(int32_t const& _return)> cob, const int32_t thing) override {
     int32_t res = _delegate->testI32(thing);
     cob(res);
   }
 
-  virtual void testI64(std::function<void(int64_t const& _return)> cob, const int64_t thing) {
+  void testI64(std::function<void(int64_t const& _return)> cob, const int64_t thing) override {
     int64_t res = _delegate->testI64(thing);
     cob(res);
   }
 
-  virtual void testDouble(std::function<void(double const& _return)> cob, const double thing) {
+  void testDouble(std::function<void(double const& _return)> cob, const double thing) override {
     double res = _delegate->testDouble(thing);
     cob(res);
   }
 
-  virtual void testBinary(std::function<void(std::string const& _return)> cob,
-                          const std::string& thing) {
+  void testBinary(std::function<void(std::string const& _return)> cob,
+                          const std::string& thing) override {
     std::string res;
     _delegate->testBinary(res, thing);
     cob(res);
   }
 
-  virtual void testStruct(std::function<void(Xtruct const& _return)> cob, const Xtruct& thing) {
+  void testStruct(std::function<void(Xtruct const& _return)> cob, const Xtruct& thing) override {
     Xtruct res;
     _delegate->testStruct(res, thing);
     cob(res);
   }
 
-  virtual void testNest(std::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) {
+  void testNest(std::function<void(Xtruct2 const& _return)> cob, const Xtruct2& thing) override {
     Xtruct2 res;
     _delegate->testNest(res, thing);
     cob(res);
   }
 
-  virtual void testMap(std::function<void(std::map<int32_t, int32_t> const& _return)> cob,
-                       const std::map<int32_t, int32_t>& thing) {
+  void testMap(std::function<void(std::map<int32_t, int32_t> const& _return)> cob,
+                       const std::map<int32_t, int32_t>& thing) override {
     std::map<int32_t, int32_t> res;
     _delegate->testMap(res, thing);
     cob(res);
   }
 
-  virtual void testStringMap(
+  void testStringMap(
       std::function<void(std::map<std::string, std::string> const& _return)> cob,
-      const std::map<std::string, std::string>& thing) {
+      const std::map<std::string, std::string>& thing) override {
     std::map<std::string, std::string> res;
     _delegate->testStringMap(res, thing);
     cob(res);
   }
 
-  virtual void testSet(std::function<void(std::set<int32_t> const& _return)> cob,
-                       const std::set<int32_t>& thing) {
+  void testSet(std::function<void(std::set<int32_t> const& _return)> cob,
+                       const std::set<int32_t>& thing) override {
     std::set<int32_t> res;
     _delegate->testSet(res, thing);
     cob(res);
   }
 
-  virtual void testList(std::function<void(std::vector<int32_t> const& _return)> cob,
-                        const std::vector<int32_t>& thing) {
+  void testList(std::function<void(std::vector<int32_t> const& _return)> cob,
+                        const std::vector<int32_t>& thing) override {
     std::vector<int32_t> res;
     _delegate->testList(res, thing);
     cob(res);
   }
 
-  virtual void testEnum(std::function<void(Numberz::type const& _return)> cob,
-                        const Numberz::type thing) {
+  void testEnum(std::function<void(Numberz::type const& _return)> cob,
+                        const Numberz::type thing) override {
     Numberz::type res = _delegate->testEnum(thing);
     cob(res);
   }
 
-  virtual void testTypedef(std::function<void(UserId const& _return)> cob, const UserId thing) {
+  void testTypedef(std::function<void(UserId const& _return)> cob, const UserId thing) override {
     UserId res = _delegate->testTypedef(thing);
     cob(res);
   }
 
-  virtual void testMapMap(
+  void testMapMap(
       std::function<void(std::map<int32_t, std::map<int32_t, int32_t> > const& _return)> cob,
-      const int32_t hello) {
+      const int32_t hello) override {
     std::map<int32_t, std::map<int32_t, int32_t> > res;
     _delegate->testMapMap(res, hello);
     cob(res);
   }
 
-  virtual void testInsanity(
+  void testInsanity(
       std::function<void(std::map<UserId, std::map<Numberz::type, Insanity> > const& _return)> cob,
-      const Insanity& argument) {
+      const Insanity& argument) override {
     std::map<UserId, std::map<Numberz::type, Insanity> > res;
     _delegate->testInsanity(res, argument);
     cob(res);
   }
 
-  virtual void testMulti(std::function<void(Xtruct const& _return)> cob,
+  void testMulti(std::function<void(Xtruct const& _return)> cob,
                          const int8_t arg0,
                          const int32_t arg1,
                          const int64_t arg2,
                          const std::map<int16_t, std::string>& arg3,
                          const Numberz::type arg4,
-                         const UserId arg5) {
+                         const UserId arg5) override {
     Xtruct res;
     _delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5);
     cob(res);
   }
 
-  virtual void testException(
+  void testException(
       std::function<void()> cob,
       std::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
-      const std::string& arg) {
+      const std::string& arg) override {
     try {
       _delegate->testException(arg);
     } catch (const apache::thrift::TException& e) {
@@ -534,11 +534,11 @@
     cob();
   }
 
-  virtual void testMultiException(
+  void testMultiException(
       std::function<void(Xtruct const& _return)> cob,
       std::function<void(::apache::thrift::TDelayedException* _throw)> exn_cob,
       const std::string& arg0,
-      const std::string& arg1) {
+      const std::string& arg1) override {
     Xtruct res;
     try {
       _delegate->testMultiException(res, arg0, arg1);
@@ -549,7 +549,7 @@
     cob(res);
   }
 
-  virtual void testOneway(std::function<void()> cob, const int32_t secondsToSleep) {
+  void testOneway(std::function<void()> cob, const int32_t secondsToSleep) override {
     _delegate->testOneway(secondsToSleep);
     cob();
   }
@@ -672,7 +672,7 @@
     std::shared_ptr<TProtocolFactory> jsonProtocolFactory(new TJSONProtocolFactory());
     protocolFactory = jsonProtocolFactory;
   } else if (protocol_type == "compact" || protocol_type == "multic") {
-    TCompactProtocolFactoryT<TBufferBase> *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>();
+    auto *compactProtocolFactory = new TCompactProtocolFactoryT<TBufferBase>();
     compactProtocolFactory->setContainerSizeLimit(container_limit);
     compactProtocolFactory->setStringSizeLimit(string_limit);
     protocolFactory.reset(compactProtocolFactory);
@@ -680,7 +680,7 @@
     std::shared_ptr<TProtocolFactory> headerProtocolFactory(new THeaderProtocolFactory());
     protocolFactory = headerProtocolFactory;
   } else {
-    TBinaryProtocolFactoryT<TBufferBase>* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>();
+    auto* binaryProtocolFactory = new TBinaryProtocolFactoryT<TBufferBase>();
     binaryProtocolFactory->setContainerSizeLimit(container_limit);
     binaryProtocolFactory->setStringSizeLimit(string_limit);
     protocolFactory.reset(binaryProtocolFactory);
@@ -810,7 +810,7 @@
     }
   }
 
-  if (server.get() != NULL) {
+  if (server.get() != nullptr) {
     if (protocol_type == "header") {
       // Tell the server to use the same protocol for input / output
       // if using header
