diff --git a/benchmark/bench_log.cpp b/benchmark/bench_log.cpp index afc23e9a9..63807b2fd 100644 --- a/benchmark/bench_log.cpp +++ b/benchmark/bench_log.cpp @@ -40,8 +40,8 @@ class IostreamWriteBench : public td::Benchmark { protected: std::string file_name_; std::ofstream stream; - enum { buffer_size = 1 << 20 }; - char buffer[buffer_size]; + static constexpr std::size_t BUFFER_SIZE = 1 << 20; + char buffer[BUFFER_SIZE]; public: std::string get_description() const override { @@ -52,7 +52,7 @@ class IostreamWriteBench : public td::Benchmark { file_name_ = create_tmp_file(); stream.open(file_name_.c_str()); CHECK(stream.is_open()); - // stream.rdbuf()->pubsetbuf(buffer, buffer_size); + // stream.rdbuf()->pubsetbuf(buffer, BUFFER_SIZE); } void run(int n) override { @@ -71,8 +71,8 @@ class FILEWriteBench : public td::Benchmark { protected: std::string file_name_; FILE *file; - enum { buffer_size = 1 << 20 }; - char buffer[buffer_size]; + static constexpr std::size_t BUFFER_SIZE = 1 << 20; + char buffer[BUFFER_SIZE]; public: std::string get_description() const override { @@ -82,7 +82,7 @@ class FILEWriteBench : public td::Benchmark { void start_up() override { file_name_ = create_tmp_file(); file = fopen(file_name_.c_str(), "w"); - // setvbuf(file, buffer, _IOFBF, buffer_size); + // setvbuf(file, buffer, _IOFBF, BUFFER_SIZE); } void run(int n) override { @@ -123,8 +123,8 @@ class LogWriteBench : public td::Benchmark { std::string file_name_; std::ofstream stream; std::streambuf *old_buf; - enum { buffer_size = 1 << 20 }; - char buffer[buffer_size]; + static constexpr std::size_t BUFFER_SIZE = 1 << 20; + char buffer[BUFFER_SIZE]; public: std::string get_description() const override { diff --git a/benchmark/bench_queue.cpp b/benchmark/bench_queue.cpp index d22b1247e..af5f48c32 100644 --- a/benchmark/bench_queue.cpp +++ b/benchmark/bench_queue.cpp @@ -837,7 +837,7 @@ class QueueBenchmark : public td::Benchmark { template class RingBenchmark : public td::Benchmark { - enum { QN = 504 }; + static constexpr int QN = 504; struct Thread { int int_id; diff --git a/td/mtproto/AuthKey.h b/td/mtproto/AuthKey.h index 443eda994..e35121f9d 100644 --- a/td/mtproto/AuthKey.h +++ b/td/mtproto/AuthKey.h @@ -66,7 +66,9 @@ class AuthKey { auth_key_.clear(); } - enum : int32 { AUTH_FLAG = 1, WAS_AUTH_FLAG = 2, HAS_CREATED_AT = 4 }; + static constexpr int32 AUTH_FLAG = 1; + static constexpr int32 WAS_AUTH_FLAG = 2; + static constexpr int32 HAS_CREATED_AT = 4; template void store(StorerT &storer) const { diff --git a/tdutils/td/utils/BufferedUdp.h b/tdutils/td/utils/BufferedUdp.h index 92c5b7635..68031dc29 100644 --- a/tdutils/td/utils/BufferedUdp.h +++ b/tdutils/td/utils/BufferedUdp.h @@ -64,7 +64,8 @@ class UdpReaderHelper { } private: - enum : size_t { MAX_PACKET_SIZE = 2048, RESERVED_SIZE = MAX_PACKET_SIZE * 8 }; + static constexpr size_t MAX_PACKET_SIZE = 2048; + static constexpr size_t RESERVED_SIZE = MAX_PACKET_SIZE * 8; UdpMessage message_; BufferSlice buffer_; }; @@ -98,7 +99,7 @@ class UdpReader { } private: - enum : size_t { BUFFER_SIZE = 16 }; + static constexpr size_t BUFFER_SIZE = 16; std::array messages_; std::array helpers_; }; diff --git a/tdutils/td/utils/port/UdpSocketFd.cpp b/tdutils/td/utils/port/UdpSocketFd.cpp index 5b25b6132..bd0efcff2 100644 --- a/tdutils/td/utils/port/UdpSocketFd.cpp +++ b/tdutils/td/utils/port/UdpSocketFd.cpp @@ -170,7 +170,8 @@ class UdpSocketFdImpl : private Iocp::Callback { UdpMessage to_receive_; WSAMSG receive_message_; UdpSocketReceiveHelper receive_helper_; - enum : size_t { MAX_PACKET_SIZE = 2048, RESERVED_SIZE = MAX_PACKET_SIZE * 8 }; + static constexpr size_t MAX_PACKET_SIZE = 2048; + static constexpr size_t RESERVED_SIZE = MAX_PACKET_SIZE * 8; BufferSlice receive_buffer_; UdpMessage to_send_;