THRIFT-4762: Applied some C++11 refactorings to the runtime library and compiler (#1719)
* make use of C++11 override keyword
* added const specifier to TTransport::getOrigin()
* added more const correctness to the compiler
* make use of auto keyword
* replaced usage of NULL with nullptr
* make use of explicitly-defaulted function definition
* extended changelog
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++) {