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/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index c826814..3e2eb81 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -58,14 +58,14 @@
class SizeGenerator {
public:
- virtual ~SizeGenerator() {}
+ virtual ~SizeGenerator() = default;
virtual unsigned int getSize() = 0;
};
class ConstantSizeGenerator : public SizeGenerator {
public:
ConstantSizeGenerator(unsigned int value) : value_(value) {}
- virtual unsigned int getSize() { return value_; }
+ unsigned int getSize() override { return value_; }
private:
unsigned int value_;
@@ -76,10 +76,10 @@
LogNormalSizeGenerator(double mean, double std_dev)
: gen_(rng, boost::lognormal_distribution<double>(mean, std_dev)) {}
- virtual unsigned int getSize() {
+ unsigned int getSize() override {
// Loop until we get a size of 1 or more
while (true) {
- unsigned int value = static_cast<unsigned int>(gen_());
+ auto value = static_cast<unsigned int>(gen_());
if (value >= 1) {
return value;
}
@@ -91,13 +91,13 @@
};
boost::shared_array<uint8_t> gen_uniform_buffer(uint32_t buf_len, uint8_t c) {
- uint8_t* buf = new uint8_t[buf_len];
+ auto* buf = new uint8_t[buf_len];
memset(buf, c, buf_len);
return boost::shared_array<uint8_t>(buf);
}
boost::shared_array<uint8_t> gen_compressible_buffer(uint32_t buf_len) {
- uint8_t* buf = new uint8_t[buf_len];
+ auto* buf = new uint8_t[buf_len];
// Generate small runs of alternately increasing and decreasing bytes
boost::uniform_smallint<uint32_t> run_length_distribution(1, 64);
@@ -129,7 +129,7 @@
}
boost::shared_array<uint8_t> gen_random_buffer(uint32_t buf_len) {
- uint8_t* buf = new uint8_t[buf_len];
+ auto* buf = new uint8_t[buf_len];
boost::uniform_smallint<uint8_t> distribution(0, UINT8_MAX);
boost::variate_generator<boost::mt19937, boost::uniform_smallint<uint8_t> >
@@ -427,7 +427,7 @@
#ifdef BOOST_TEST_DYN_LINK
bool init_unit_test_suite() {
- uint32_t seed = static_cast<uint32_t>(time(NULL));
+ auto seed = static_cast<uint32_t>(time(nullptr));
#ifdef HAVE_INTTYPES_H
printf("seed: %" PRIu32 "\n", seed);
#endif