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/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp
index 3b5ce40..635afef 100644
--- a/tutorial/cpp/CppServer.cpp
+++ b/tutorial/cpp/CppServer.cpp
@@ -46,16 +46,16 @@
class CalculatorHandler : public CalculatorIf {
public:
- CalculatorHandler() {}
+ CalculatorHandler() = default;
- void ping() { cout << "ping()" << endl; }
+ void ping() override { cout << "ping()" << endl; }
- int32_t add(const int32_t n1, const int32_t n2) {
+ int32_t add(const int32_t n1, const int32_t n2) override {
cout << "add(" << n1 << ", " << n2 << ")" << endl;
return n1 + n2;
}
- int32_t calculate(const int32_t logid, const Work& work) {
+ int32_t calculate(const int32_t logid, const Work& work) override {
cout << "calculate(" << logid << ", " << work << ")" << endl;
int32_t val;
@@ -94,12 +94,12 @@
return val;
}
- void getStruct(SharedStruct& ret, const int32_t logid) {
+ void getStruct(SharedStruct& ret, const int32_t logid) override {
cout << "getStruct(" << logid << ")" << endl;
ret = log[logid];
}
- void zip() { cout << "zip()" << endl; }
+ void zip() override { cout << "zip()" << endl; }
protected:
map<int32_t, SharedStruct> log;
@@ -113,8 +113,8 @@
*/
class CalculatorCloneFactory : virtual public CalculatorIfFactory {
public:
- virtual ~CalculatorCloneFactory() {}
- virtual CalculatorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo)
+ ~CalculatorCloneFactory() override = default;
+ CalculatorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) override
{
std::shared_ptr<TSocket> sock = std::dynamic_pointer_cast<TSocket>(connInfo.transport);
cout << "Incoming connection\n";
@@ -124,7 +124,7 @@
cout << "\tPeerPort: " << sock->getPeerPort() << "\n";
return new CalculatorHandler;
}
- virtual void releaseHandler( ::shared::SharedServiceIf* handler) {
+ void releaseHandler( ::shared::SharedServiceIf* handler) override {
delete handler;
}
};