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/lib/cpp/test/TServerIntegrationTest.cpp b/lib/cpp/test/TServerIntegrationTest.cpp
index a7680d8..b88c35b 100644
--- a/lib/cpp/test/TServerIntegrationTest.cpp
+++ b/lib/cpp/test/TServerIntegrationTest.cpp
@@ -74,21 +74,21 @@
class TServerReadyEventHandler : public TServerEventHandler, public Monitor {
public:
TServerReadyEventHandler() : isListening_(false), accepted_(0) {}
- virtual ~TServerReadyEventHandler() {}
- virtual void preServe() {
+ ~TServerReadyEventHandler() override = default;
+ void preServe() override {
Synchronized sync(*this);
isListening_ = true;
notify();
}
- virtual void* createContext(shared_ptr<TProtocol> input,
- shared_ptr<TProtocol> output) {
+ void* createContext(shared_ptr<TProtocol> input,
+ shared_ptr<TProtocol> output) override {
Synchronized sync(*this);
++accepted_;
notify();
(void)input;
(void)output;
- return NULL;
+ return nullptr;
}
bool isListening() const { return isListening_; }
uint64_t acceptedCount() const { return accepted_; }
@@ -105,36 +105,36 @@
public:
ParentHandler() : generation_(0) {}
- int32_t incrementGeneration() {
+ int32_t incrementGeneration() override {
Guard g(mutex_);
return ++generation_;
}
- int32_t getGeneration() {
+ int32_t getGeneration() override {
Guard g(mutex_);
return generation_;
}
- void addString(const std::string& s) {
+ void addString(const std::string& s) override {
Guard g(mutex_);
strings_.push_back(s);
}
- void getStrings(std::vector<std::string>& _return) {
+ void getStrings(std::vector<std::string>& _return) override {
Guard g(mutex_);
_return = strings_;
}
- void getDataWait(std::string& _return, const int32_t length) {
+ void getDataWait(std::string& _return, const int32_t length) override {
THRIFT_UNUSED_VARIABLE(_return);
THRIFT_UNUSED_VARIABLE(length);
}
- void onewayWait() {}
+ void onewayWait() override {}
- void exceptionWait(const std::string& message) { THRIFT_UNUSED_VARIABLE(message); }
+ void exceptionWait(const std::string& message) override { THRIFT_UNUSED_VARIABLE(message); }
- void unexpectedExceptionWait(const std::string& message) { THRIFT_UNUSED_VARIABLE(message); }
+ void unexpectedExceptionWait(const std::string& message) override { THRIFT_UNUSED_VARIABLE(message); }
protected:
Mutex mutex_;
@@ -264,7 +264,7 @@
* \returns the server port number
*/
int getServerPort() {
- TServerSocket* pSock = dynamic_cast<TServerSocket*>(pServer->getServerTransport().get());
+ auto* pSock = dynamic_cast<TServerSocket*>(pServer->getServerTransport().get());
if (!pSock) { throw std::logic_error("how come?"); }
return pSock->getPort();
}