mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-09 00:13:31 +00:00
Remove redundant const in static constexpr const
From http://en.cppreference.com/w/cpp/language/constexpr: A constexpr specifier used in an object declaration implies const. However, We can not change from static constexpr const char* TIME_FORMAT = "%a %b %d %I:%M:%S %Z %Y"; to static constexpr char* TIME_FORMAT = "%a %b %d %I:%M:%S %Z %Y"; The compiler complains: In file included from json/formatter.cc:22:0: json/formatter.hh:132:42: error: deprecated conversion from string constant to ‘char*’ [-Werror=write-strings] static constexpr char* TIME_FORMAT = "%a %b %d %I:%M:%S %Z %Y"; Since, unlike const, constexpr does not modify a type. It just applies to an object (or function), and incidentally implies const to the top-level type.
This commit is contained in:
@@ -219,8 +219,8 @@ struct future_state {
|
||||
template <>
|
||||
struct future_state<> {
|
||||
static_assert(sizeof(std::exception_ptr) == sizeof(void*), "exception_ptr not a pointer");
|
||||
static constexpr const bool move_noexcept = true;
|
||||
static constexpr const bool copy_noexcept = true;
|
||||
static constexpr bool move_noexcept = true;
|
||||
static constexpr bool copy_noexcept = true;
|
||||
enum class state : uintptr_t {
|
||||
invalid = 0,
|
||||
future = 1,
|
||||
@@ -310,8 +310,8 @@ class promise {
|
||||
future_state<T...> _local_state;
|
||||
future_state<T...>* _state;
|
||||
std::unique_ptr<task> _task;
|
||||
static constexpr const bool move_noexcept = future_state<T...>::move_noexcept;
|
||||
static constexpr const bool copy_noexcept = future_state<T...>::copy_noexcept;
|
||||
static constexpr bool move_noexcept = future_state<T...>::move_noexcept;
|
||||
static constexpr bool copy_noexcept = future_state<T...>::copy_noexcept;
|
||||
public:
|
||||
promise() noexcept : _state(&_local_state) {}
|
||||
promise(promise&& x) noexcept(move_noexcept) : _future(x._future), _state(x._state), _task(std::move(x._task)) {
|
||||
@@ -434,8 +434,8 @@ template <typename... T>
|
||||
class future {
|
||||
promise<T...>* _promise;
|
||||
future_state<T...> _local_state; // valid if !_promise
|
||||
static constexpr const bool move_noexcept = future_state<T...>::move_noexcept;
|
||||
static constexpr const bool copy_noexcept = future_state<T...>::copy_noexcept;
|
||||
static constexpr bool move_noexcept = future_state<T...>::move_noexcept;
|
||||
static constexpr bool copy_noexcept = future_state<T...>::copy_noexcept;
|
||||
private:
|
||||
future(promise<T...>* pr) noexcept : _promise(pr) {
|
||||
_promise->_future = this;
|
||||
|
||||
@@ -73,9 +73,9 @@
|
||||
|
||||
namespace memory {
|
||||
|
||||
static constexpr const unsigned cpu_id_shift = 36; // FIXME: make dynamic
|
||||
static constexpr const unsigned max_cpus = 256;
|
||||
static constexpr const size_t cache_line_size = 64;
|
||||
static constexpr unsigned cpu_id_shift = 36; // FIXME: make dynamic
|
||||
static constexpr unsigned max_cpus = 256;
|
||||
static constexpr size_t cache_line_size = 64;
|
||||
|
||||
using pageidx = uint32_t;
|
||||
|
||||
@@ -227,7 +227,7 @@ small_pool::size_to_idx(unsigned size) {
|
||||
|
||||
class small_pool_array {
|
||||
public:
|
||||
static constexpr const unsigned nr_small_pools = small_pool::size_to_idx(4 * page_size) + 1;
|
||||
static constexpr unsigned nr_small_pools = small_pool::size_to_idx(4 * page_size) + 1;
|
||||
private:
|
||||
union u {
|
||||
small_pool a[nr_small_pools];
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
small_pool& operator[](unsigned idx) { return _u.a[idx]; }
|
||||
};
|
||||
|
||||
static constexpr const size_t max_small_allocation
|
||||
static constexpr size_t max_small_allocation
|
||||
= small_pool::idx_to_size(small_pool_array::nr_small_pools - 1);
|
||||
|
||||
struct cross_cpu_free_item {
|
||||
@@ -262,7 +262,7 @@ struct cpu_pages {
|
||||
unsigned cpu_id = -1U;
|
||||
std::function<void (std::function<void ()>)> reclaim_hook;
|
||||
std::vector<reclaimer*> reclaimers;
|
||||
static constexpr const unsigned nr_span_lists = 32;
|
||||
static constexpr unsigned nr_span_lists = 32;
|
||||
union pla {
|
||||
pla() {
|
||||
for (auto&& e : free_spans) {
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
namespace memory {
|
||||
|
||||
// TODO: Use getpagesize() in order to learn a size of a system PAGE.
|
||||
static constexpr const size_t page_bits = 12;
|
||||
static constexpr const size_t page_size = 1 << page_bits; // 4K
|
||||
static constexpr const size_t huge_page_size = 512 * page_size; // 2M
|
||||
static constexpr size_t page_bits = 12;
|
||||
static constexpr size_t page_size = 1 << page_bits; // 4K
|
||||
static constexpr size_t huge_page_size = 512 * page_size; // 2M
|
||||
|
||||
void configure(std::vector<resource::memory> m,
|
||||
std::experimental::optional<std::string> hugetlbfs_path = {});
|
||||
|
||||
@@ -46,7 +46,7 @@ extern thread_local jmp_buf g_unthreaded_context;
|
||||
// \c thread itself because \c thread is movable, and we want pointers
|
||||
// to this state to be captured.
|
||||
class thread_context {
|
||||
static constexpr const size_t _stack_size = 128*1024;
|
||||
static constexpr size_t _stack_size = 128*1024;
|
||||
std::unique_ptr<char[]> _stack{new char[_stack_size]};
|
||||
std::function<void ()> _func;
|
||||
jmp_buf _context;
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
constexpr static const char* TIME_FORMAT = "%a %b %d %I:%M:%S %Z %Y";
|
||||
static constexpr const char* TIME_FORMAT = "%a %b %d %I:%M:%S %Z %Y";
|
||||
|
||||
};
|
||||
|
||||
|
||||
22
net/tcp.hh
22
net/tcp.hh
@@ -212,17 +212,17 @@ private:
|
||||
|
||||
class tcb : public enable_lw_shared_from_this<tcb> {
|
||||
using clock_type = lowres_clock;
|
||||
static constexpr const tcp_state CLOSED = tcp_state::CLOSED;
|
||||
static constexpr const tcp_state LISTEN = tcp_state::LISTEN;
|
||||
static constexpr const tcp_state SYN_SENT = tcp_state::SYN_SENT;
|
||||
static constexpr const tcp_state SYN_RECEIVED = tcp_state::SYN_RECEIVED;
|
||||
static constexpr const tcp_state ESTABLISHED = tcp_state::ESTABLISHED;
|
||||
static constexpr const tcp_state FIN_WAIT_1 = tcp_state::FIN_WAIT_1;
|
||||
static constexpr const tcp_state FIN_WAIT_2 = tcp_state::FIN_WAIT_2;
|
||||
static constexpr const tcp_state CLOSE_WAIT = tcp_state::CLOSE_WAIT;
|
||||
static constexpr const tcp_state CLOSING = tcp_state::CLOSING;
|
||||
static constexpr const tcp_state LAST_ACK = tcp_state::LAST_ACK;
|
||||
static constexpr const tcp_state TIME_WAIT = tcp_state::TIME_WAIT;
|
||||
static constexpr tcp_state CLOSED = tcp_state::CLOSED;
|
||||
static constexpr tcp_state LISTEN = tcp_state::LISTEN;
|
||||
static constexpr tcp_state SYN_SENT = tcp_state::SYN_SENT;
|
||||
static constexpr tcp_state SYN_RECEIVED = tcp_state::SYN_RECEIVED;
|
||||
static constexpr tcp_state ESTABLISHED = tcp_state::ESTABLISHED;
|
||||
static constexpr tcp_state FIN_WAIT_1 = tcp_state::FIN_WAIT_1;
|
||||
static constexpr tcp_state FIN_WAIT_2 = tcp_state::FIN_WAIT_2;
|
||||
static constexpr tcp_state CLOSE_WAIT = tcp_state::CLOSE_WAIT;
|
||||
static constexpr tcp_state CLOSING = tcp_state::CLOSING;
|
||||
static constexpr tcp_state LAST_ACK = tcp_state::LAST_ACK;
|
||||
static constexpr tcp_state TIME_WAIT = tcp_state::TIME_WAIT;
|
||||
tcp_state _state = CLOSED;
|
||||
tcp& _tcp;
|
||||
connection* _conn = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user