Skip to content

Commit 2cffe55

Browse files
committed
Update constants to use static constexpr
1 parent 5aaa78a commit 2cffe55

File tree

10 files changed

+38
-38
lines changed

10 files changed

+38
-38
lines changed

include/libconcur/concurrent.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,15 @@ struct producer<trans::broadcast, relation::multi> {
379379
private:
380380
friend struct producer::header_impl;
381381

382-
constexpr static index_t get_index(state::flag_t flags) noexcept {
382+
static constexpr index_t get_index(state::flag_t flags) noexcept {
383383
return index_t(flags);
384384
}
385385

386-
constexpr static index_t get_begin(state::flag_t flags) noexcept {
386+
static constexpr index_t get_begin(state::flag_t flags) noexcept {
387387
return index_t(flags >> (sizeof(index_t) * CHAR_BIT));
388388
}
389389

390-
constexpr static state::flag_t make_flags(index_t idx, index_t beg) noexcept {
390+
static constexpr state::flag_t make_flags(index_t idx, index_t beg) noexcept {
391391
return state::flag_t(idx) | (state::flag_t(beg) << (sizeof(index_t) * CHAR_BIT));
392392
}
393393
};

include/libimp/countof.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct trait_has_size {
2929
static std::false_type check(...);
3030
public:
3131
using type = decltype(check<T>(nullptr));
32-
constexpr static auto value = type::value;
32+
static constexpr auto value = type::value;
3333
};
3434

3535
template <typename T>
@@ -41,7 +41,7 @@ struct trait_has_Size {
4141
static std::false_type check(...);
4242
public:
4343
using type = decltype(check<T>(nullptr));
44-
constexpr static auto value = type::value;
44+
static constexpr auto value = type::value;
4545
};
4646

4747
template <typename C, bool = trait_has_size<C>::value
@@ -50,21 +50,21 @@ struct trait;
5050

5151
template <typename T, std::size_t N>
5252
struct trait<T[N], false, false> {
53-
constexpr static auto countof(T const (&)[N]) noexcept {
53+
static constexpr auto countof(T const (&)[N]) noexcept {
5454
return N;
5555
}
5656
};
5757

5858
template <typename C, bool B>
5959
struct trait<C, true, B> {
60-
constexpr static auto countof(C const &c) noexcept(noexcept(c.size())) {
60+
static constexpr auto countof(C const &c) noexcept(noexcept(c.size())) {
6161
return c.size();
6262
}
6363
};
6464

6565
template <typename C>
6666
struct trait<C, false, true> {
67-
constexpr static auto countof(C const &c) noexcept(noexcept(c.Size())) {
67+
static constexpr auto countof(C const &c) noexcept(noexcept(c.Size())) {
6868
return c.Size();
6969
}
7070
};

include/libimp/dataof.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct trait_has_data {
2929
static std::false_type check(...);
3030
public:
3131
using type = decltype(check<T>(nullptr));
32-
constexpr static auto value = type::value;
32+
static constexpr auto value = type::value;
3333
};
3434

3535
template <typename T>
@@ -41,7 +41,7 @@ struct trait_has_Data {
4141
static std::false_type check(...);
4242
public:
4343
using type = decltype(check<T>(nullptr));
44-
constexpr static auto value = type::value;
44+
static constexpr auto value = type::value;
4545
};
4646

4747
template <typename C, bool = trait_has_data<C>::value
@@ -50,38 +50,38 @@ struct trait;
5050

5151
template <typename T, std::size_t N>
5252
struct trait<T[N], false, false> {
53-
constexpr static T const *dataof(T const (&arr)[N]) noexcept {
53+
static constexpr T const *dataof(T const (&arr)[N]) noexcept {
5454
return arr;
5555
}
56-
constexpr static T *dataof(T (&arr)[N]) noexcept {
56+
static constexpr T *dataof(T (&arr)[N]) noexcept {
5757
return arr;
5858
}
5959
};
6060

6161
template <typename C, bool B>
6262
struct trait<C, true, B> {
6363
template <typename T>
64-
constexpr static auto dataof(T &&c) noexcept(noexcept(c.data())) {
64+
static constexpr auto dataof(T &&c) noexcept(noexcept(c.data())) {
6565
return std::forward<T>(c).data();
6666
}
6767
};
6868

6969
template <typename C>
7070
struct trait<C, false, true> {
7171
template <typename T>
72-
constexpr static auto dataof(T &&c) noexcept(noexcept(c.Data())) {
72+
static constexpr auto dataof(T &&c) noexcept(noexcept(c.Data())) {
7373
return std::forward<T>(c).Data();
7474
}
7575
};
7676

7777
template <typename C>
7878
struct trait<C, false, false> {
7979
template <typename T>
80-
constexpr static T const *dataof(std::initializer_list<T> il) noexcept {
80+
static constexpr T const *dataof(std::initializer_list<T> il) noexcept {
8181
return il.begin();
8282
}
8383
template <typename T>
84-
constexpr static T const *dataof(T const *p) noexcept {
84+
static constexpr T const *dataof(T const *p) noexcept {
8585
return p;
8686
}
8787
};

include/libimp/log.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool unfold_tuple_fmt_to(fmt_context &ctx, Tp const &tp, std::index_sequence<I..
5454

5555
template <typename... T>
5656
bool context_to_string(fmt_context &f_ctx, context<T...> const &l_ctx) noexcept {
57-
constexpr static char types[] = {
57+
static constexpr char types[] = {
5858
'T', 'D', 'I', 'W', 'E', 'F',
5959
};
6060
LIBIMP_TRY {

include/libimp/result.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ struct generic_traits {
4141
using storage_t = std::tuple<T, std::error_code>;
4242

4343
/// \brief Custom initialization.
44-
constexpr static void init_code(storage_t &code) noexcept {
44+
static constexpr void init_code(storage_t &code) noexcept {
4545
code = {{}, std::error_code(-1, std::generic_category())};
4646
}
47-
constexpr static void init_code(storage_t &code, T value, std::error_code const &ec) noexcept {
47+
static constexpr void init_code(storage_t &code, T value, std::error_code const &ec) noexcept {
4848
code = {value, ec};
4949
}
50-
constexpr static void init_code(storage_t &code, T value) noexcept {
50+
static constexpr void init_code(storage_t &code, T value) noexcept {
5151
code = {value, {}};
5252
}
53-
constexpr static void init_code(storage_t &code, std::error_code const &ec) noexcept {
53+
static constexpr void init_code(storage_t &code, std::error_code const &ec) noexcept {
5454
code = {{}, ec};
5555
}
5656

5757
/// \brief Custom type data acquisition.
58-
constexpr static T get_value(storage_t const &code) noexcept {
58+
static constexpr T get_value(storage_t const &code) noexcept {
5959
return std::get<0>(code);
6060
}
61-
constexpr static bool get_ok(storage_t const &code) noexcept {
61+
static constexpr bool get_ok(storage_t const &code) noexcept {
6262
return !std::get<1>(code);
6363
}
64-
constexpr static std::error_code get_error(storage_t const &code) noexcept {
64+
static constexpr std::error_code get_error(storage_t const &code) noexcept {
6565
return std::get<1>(code);
6666
}
6767
};
@@ -72,18 +72,18 @@ struct default_traits<void, ___> {
7272
using storage_t = std::error_code;
7373

7474
/// \brief Custom initialization.
75-
constexpr static void init_code(storage_t &code) noexcept {
75+
static constexpr void init_code(storage_t &code) noexcept {
7676
code = std::error_code(-1, std::generic_category());
7777
}
78-
constexpr static void init_code(storage_t &code, std::error_code const &ec) noexcept {
78+
static constexpr void init_code(storage_t &code, std::error_code const &ec) noexcept {
7979
code = ec;
8080
}
8181

8282
/// \brief Custom type data acquisition.
83-
constexpr static bool get_ok(storage_t const &code) noexcept {
83+
static constexpr bool get_ok(storage_t const &code) noexcept {
8484
return !code;
8585
}
86-
constexpr static std::error_code get_error(storage_t const &code) noexcept {
86+
static constexpr std::error_code get_error(storage_t const &code) noexcept {
8787
return code;
8888
}
8989

@@ -94,7 +94,7 @@ struct default_traits<void, ___> {
9494
template <typename T>
9595
struct default_traits<T, std::enable_if_t<std::is_integral<T>::value>> : generic_traits<T> {
9696
/// \brief Custom initialization.
97-
constexpr static void init_code(typename generic_traits<T>::storage_t &code,
97+
static constexpr void init_code(typename generic_traits<T>::storage_t &code,
9898
T value, bool ok) noexcept {
9999
code = {value, ok ? std::error_code() : std::error_code(-1, std::generic_category())};
100100
}
@@ -107,11 +107,11 @@ struct default_traits<T, std::enable_if_t<std::is_integral<T>::value>> : generic
107107
template <typename T>
108108
struct default_traits<T, std::enable_if_t<std::is_pointer<T>::value>> : generic_traits<T> {
109109
/// \brief Custom initialization.
110-
constexpr static void init_code(typename generic_traits<T>::storage_t &code,
110+
static constexpr void init_code(typename generic_traits<T>::storage_t &code,
111111
std::nullptr_t, std::error_code const &ec) noexcept {
112112
code = {nullptr, ec};
113113
}
114-
constexpr static void init_code(typename generic_traits<T>::storage_t &code,
114+
static constexpr void init_code(typename generic_traits<T>::storage_t &code,
115115
std::nullptr_t) noexcept {
116116
code = {nullptr, std::error_code(-1, std::generic_category())};
117117
}

include/libpmr/block_pool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class block_pool<0, 0> {
163163
using central_cache_pool_t = central_cache_pool<block_t, 0>;
164164

165165
public:
166-
constexpr static std::size_t block_size = 0;
166+
static constexpr std::size_t block_size = 0;
167167

168168
block_pool() noexcept : cursor_(central_cache_pool_t::instance().aqueire()) {}
169169
~block_pool() noexcept {
@@ -202,7 +202,7 @@ class block_pool {
202202
}
203203

204204
public:
205-
constexpr static std::size_t block_size = BlockSize;
205+
static constexpr std::size_t block_size = BlockSize;
206206

207207
block_pool() noexcept : cursor_(expand()) {}
208208
~block_pool() noexcept {

include/libpmr/small_storage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class holder<void, false> : public holder_base {
494494
template <std::size_t N>
495495
class small_storage {
496496

497-
constexpr static std::size_t storage_size = sizeof(holder<void *, false>) - sizeof(void *) + N;
497+
static constexpr std::size_t storage_size = sizeof(holder<void *, false>) - sizeof(void *) + N;
498498
static_assert(storage_size >= sizeof(holder<void *, false>), "N is not large enough to hold a pointer.");
499499

500500
alignas(std::max_align_t) std::array<::LIBIMP::byte, storage_size> storage_;

src/libimp/fmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LIBIMP_NAMESPACE_BEG_
2121
namespace {
2222

2323
struct sfmt_policy {
24-
constexpr static std::size_t aligned_size = 32U;
24+
static constexpr std::size_t aligned_size = 32U;
2525
};
2626

2727
template <typename Policy = sfmt_policy>

test/concur/test_concur_circular_queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void test_queue(std::size_t np, std::size_t nc) {
9393
};
9494
circular_queue<Data, PR, CR> que;
9595

96-
constexpr static std::uint32_t loop_size = 10'0000;
96+
static constexpr std::uint32_t loop_size = 10'0000;
9797

9898
std::atomic<std::uint64_t> sum {0};
9999
std::atomic<std::size_t> running {np};

test/concur/test_concur_concurrent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void test_unicast(std::size_t np, std::size_t nc) {
9595
LIBIMP_LOG_();
9696
log.info("\n\tStart with: ", imp::nameof<PC>(), ", ", np, " producers, ", nc, " consumers...");
9797

98-
constexpr static std::uint32_t loop_size = 100'0000;
98+
static constexpr std::uint32_t loop_size = 100'0000;
9999

100100
concur::element<std::uint64_t> circ[32] {};
101101
PC pc;
@@ -232,7 +232,7 @@ void test_broadcast(std::size_t np, std::size_t nc) {
232232
typename concur::traits<PC>::header hdr {imp::make_span(circ)};
233233
ASSERT_TRUE(hdr.valid());
234234

235-
constexpr static std::uint32_t loop_size = 10'0000;
235+
static constexpr std::uint32_t loop_size = 10'0000;
236236

237237
std::atomic<std::uint64_t> sum {0};
238238
std::atomic<std::size_t> running {np};

0 commit comments

Comments
 (0)