refactor 'constexpr const'->'constexpr'

This commit is contained in:
2025-04-29 14:45:17 -05:00
parent a09fd441d3
commit d86e40ab15
102 changed files with 364 additions and 381 deletions

View File

@ -75,7 +75,7 @@ template <typename val_t>
-> bool {
REPERTORY_USES_FUNCTION_NAME();
static constexpr const auto base16{16};
static constexpr auto base16{16};
try {
val.clear();
@ -158,7 +158,7 @@ template <typename col_t>
inline auto to_hex_string(const col_t &collection) -> std::string {
static_assert(sizeof(typename col_t::value_type) == 1U,
"value_type must be 1 byte in size");
static constexpr const auto mask = 0xFF;
static constexpr auto mask{0xFF};
std::stringstream stream{};
for (auto &&val : collection) {

View File

@ -429,14 +429,14 @@ using unique_recur_mutex_lock = std::unique_lock<std::recursive_mutex>;
#if defined(_WIN32)
#if defined(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
inline constexpr const auto max_path_length = std::size_t{32767U};
inline constexpr auto max_path_length = std::size_t{32767U};
#else // !defined(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
inline constexpr const auto max_path_length = std::size_t{MAX_PATH};
inline constexpr auto max_path_length = std::size_t{MAX_PATH};
#endif // defined(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
using native_handle = HANDLE;
#else // !defined(_WIN32)
inline constexpr const auto max_path_length = std::size_t{PATH_MAX};
inline constexpr auto max_path_length = std::size_t{PATH_MAX};
using native_handle = int;
#if !defined(INVALID_HANDLE_VALUE)
#define INVALID_HANDLE_VALUE (-1)
@ -482,7 +482,7 @@ using http_ranges = std::vector<http_range>;
#endif // defined(__cplusplus)
#define REPERTORY_USES_FUNCTION_NAME() \
static constexpr const std::string_view function_name { \
static constexpr std::string_view function_name { \
static_cast<const char *>(__FUNCTION__), \
}

View File

@ -29,7 +29,7 @@
#include "utils/hash.hpp"
namespace repertory::utils::encryption {
inline constexpr const std::uint32_t encryption_header_size{
inline constexpr std::uint32_t encryption_header_size{
crypto_aead_xchacha20poly1305_IETF_NPUBBYTES +
crypto_aead_xchacha20poly1305_IETF_ABYTES,
};

View File

@ -26,30 +26,30 @@
#include "utils/string.hpp"
namespace repertory::utils::path {
inline constexpr const std::string_view backslash{"\\"};
inline constexpr const std::wstring_view backslash_w{L"\\"};
inline constexpr const std::string_view dot{"."};
inline constexpr const std::wstring_view dot_w{L"."};
inline constexpr const std::string_view dot_backslash{".\\"};
inline constexpr const std::wstring_view dot_backslash_w{L".\\"};
inline constexpr const std::string_view dot_slash{"./"};
inline constexpr const std::wstring_view dot_slash_w{L"./"};
inline constexpr const std::string_view long_notation{"\\\\?\\"};
inline constexpr const std::wstring_view long_notation_w{L"\\\\?\\"};
inline constexpr const std::string_view slash{"/"};
inline constexpr const std::wstring_view slash_w{L"/"};
inline constexpr std::string_view backslash{"\\"};
inline constexpr std::wstring_view backslash_w{L"\\"};
inline constexpr std::string_view dot{"."};
inline constexpr std::wstring_view dot_w{L"."};
inline constexpr std::string_view dot_backslash{".\\"};
inline constexpr std::wstring_view dot_backslash_w{L".\\"};
inline constexpr std::string_view dot_slash{"./"};
inline constexpr std::wstring_view dot_slash_w{L"./"};
inline constexpr std::string_view long_notation{"\\\\?\\"};
inline constexpr std::wstring_view long_notation_w{L"\\\\?\\"};
inline constexpr std::string_view slash{"/"};
inline constexpr std::wstring_view slash_w{L"/"};
#if defined(_WIN32)
inline constexpr const std::string_view directory_seperator{backslash};
inline constexpr const std::wstring_view directory_seperator_w{backslash_w};
inline constexpr const std::string_view not_directory_seperator{slash};
inline constexpr const std::wstring_view not_directory_seperator_w{slash_w};
inline constexpr const std::string_view unc_notation{"\\\\"};
inline constexpr const std::wstring_view unc_notation_w{L"\\\\"};
inline constexpr std::string_view directory_seperator{backslash};
inline constexpr std::wstring_view directory_seperator_w{backslash_w};
inline constexpr std::string_view not_directory_seperator{slash};
inline constexpr std::wstring_view not_directory_seperator_w{slash_w};
inline constexpr std::string_view unc_notation{"\\\\"};
inline constexpr std::wstring_view unc_notation_w{L"\\\\"};
#else // !defined(_WIN32)
inline constexpr const std::string_view directory_seperator{slash};
inline constexpr const std::wstring_view directory_seperator_w{slash_w};
inline constexpr const std::string_view not_directory_seperator{backslash};
inline constexpr const std::wstring_view not_directory_seperator_w{backslash_w};
inline constexpr std::string_view directory_seperator{slash};
inline constexpr std::wstring_view directory_seperator_w{slash_w};
inline constexpr std::string_view not_directory_seperator{backslash};
inline constexpr std::wstring_view not_directory_seperator_w{backslash_w};
#endif // defined(_WIN32)
template <typename char_t>

View File

@ -25,9 +25,9 @@
#include "utils/config.hpp"
namespace repertory::utils::time {
inline constexpr const auto NANOS_PER_SECOND{1000000000ULL};
inline constexpr const auto WIN32_TIME_CONVERSION{116444736000000000ULL};
inline constexpr const auto WIN32_TIME_NANOS_PER_TICK{100ULL};
inline constexpr auto NANOS_PER_SECOND{1000000000ULL};
inline constexpr auto WIN32_TIME_CONVERSION{116444736000000000ULL};
inline constexpr auto WIN32_TIME_NANOS_PER_TICK{100ULL};
#if defined(PROJECT_ENABLE_SPDLOG) || defined(PROJECT_ENABLE_FMT)
[[nodiscard]] inline auto convert_to_utc(time_t time) -> std::time_t {

View File

@ -119,8 +119,8 @@ auto get_free_drive_space(std::string_view path)
try {
#if defined(_WIN32)
ULARGE_INTEGER li{};
if (not::GetDiskFreeSpaceEx(std::string{path}.c_str(), &li, nullptr,
nullptr)) {
if (not ::GetDiskFreeSpaceEx(std::string{path}.c_str(), &li, nullptr,
nullptr)) {
throw utils::error::create_exception(
function_name, {
"failed to get free disk space",
@ -276,8 +276,8 @@ auto get_total_drive_space(std::string_view path)
try {
#if defined(_WIN32)
ULARGE_INTEGER li{};
if (not::GetDiskFreeSpaceEx(std::string{path}.c_str(), nullptr, &li,
nullptr)) {
if (not ::GetDiskFreeSpaceEx(std::string{path}.c_str(), nullptr, &li,
nullptr)) {
throw utils::error::create_exception(
function_name, {
"failed to get total disk space",
@ -376,7 +376,7 @@ auto read_json_file(std::string_view path, nlohmann::json &data) -> bool {
try {
auto abs_path = utils::path::absolute(path);
auto file = file::open_file(abs_path);
if (not*file) {
if (not *file) {
return false;
}
@ -498,7 +498,7 @@ auto write_json_file(std::wstring_view path, const nlohmann::json &data)
#endif // defined(PROJECT_ENABLE_JSON)
#if defined(PROJECT_ENABLE_LIBDSM)
static constexpr const auto validate_smb_path =
static constexpr auto validate_smb_path =
[](std::string_view path) -> bool {
return (not utils::string::begins_with(path, "///") &&
utils::string::begins_with(path, "//") &&

View File

@ -152,19 +152,19 @@ auto find_program_in_path(const std::string &name_without_extension)
}
#if defined(_WIN32)
static constexpr const std::array<std::string_view, 4U> extension_list{
static constexpr std::array<std::string_view, 4U> extension_list{
".bat",
".cmd",
".exe",
".ps1",
};
static constexpr const auto split_char = ';';
static constexpr auto split_char = ';';
#else // !defined(_WIN32)
static constexpr const std::array<std::string_view, 2U> extension_list{
static constexpr std::array<std::string_view, 2U> extension_list{
"",
".sh",
};
static constexpr const auto split_char = ':';
static constexpr auto split_char = ':';
#endif // defined(_WIN32)
auto search_path_list = utils::string::split(path, split_char, false);
@ -274,18 +274,18 @@ auto strip_to_file_name(std::wstring path) -> std::wstring {
}
auto unmake_file_uri(std::string_view uri) -> std::string {
static constexpr const std::array<std::string_view, 23U> escape_characters = {
static constexpr std::array<std::string_view, 23U> escape_characters = {
{
" ", "<", ">", "#", "%", "+", "{", "}", "|", "\\", "^", "~",
"[", "]", "`", ";", "/", "?", ":", "@", "=", "&", "$",
}};
static constexpr const std::array<std::string_view, 23U>
static constexpr std::array<std::string_view, 23U>
escape_sequences_lower = {{
"%20", "%3c", "%3e", "%23", "%25", "%2b", "%7b", "%7d",
"%7c", "%5c", "%5e", "%7e", "%5b", "%5d", "%60", "%3b",
"%2f", "%3f", "%3a", "%40", "%3d", "%26", "%24",
}};
static constexpr const std::array<std::string_view, 23U>
static constexpr std::array<std::string_view, 23U>
escape_sequences_upper = {{
"%20", "%3C", "%3E", "%23", "%25", "%2B", "%7B", "%7D",
"%7C", "%5C", "%5E", "%7E", "%5B", "%5D", "%60", "%3B",

View File

@ -183,7 +183,7 @@ TEST(utils_common, divide_with_ceiling) {
}
TEST(utils_common, generate_random_between_for_signed_integers) {
static constexpr const auto max_iterations{1000000UL};
static constexpr auto max_iterations{1000000UL};
for (std::size_t idx = 0U; idx < max_iterations; ++idx) {
auto res = utils::generate_random_between(5, 12);
@ -205,7 +205,7 @@ TEST(utils_common, generate_random_between_for_signed_integers) {
}
TEST(utils_common, generate_random_between_for_unsigned_integers) {
static constexpr const auto max_iterations{1000000UL};
static constexpr auto max_iterations{1000000UL};
for (std::size_t idx = 0U; idx < max_iterations; ++idx) {
auto res = utils::generate_random_between(5U, 12U);
@ -239,7 +239,7 @@ TEST(utils_common, generate_random_between_throws_error_on_invalid_range) {
}
TEST(utils_common, generate_random_string) {
static constexpr const auto max_iterations{10000L};
static constexpr auto max_iterations{10000L};
const auto test_string = [](auto str) {
static std::vector<decltype(str)> list{};
@ -267,7 +267,7 @@ TEST(utils_common, generate_random_string_for_zero_length) {
}
TEST(utils_common, get_environment_variable) {
static constexpr const std::string path_env{"PATH"};
static constexpr std::string path_env{"PATH"};
std::string path;
#if defined(_WIN32)

View File

@ -28,8 +28,8 @@ const auto get_stop_requested = []() -> bool { return false; };
} // namespace
namespace repertory {
static constexpr const std::string_view token{"moose"};
static constexpr const std::wstring_view token_w{L"moose"};
static constexpr std::string_view token{"moose"};
static constexpr std::wstring_view token_w{L"moose"};
TEST(utils_encryption, generate_key) {
auto key1 =

View File

@ -24,9 +24,9 @@
namespace {
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
#include "utils/file_enc_file.hpp"
constexpr const auto file_type_count{3U};
constexpr auto file_type_count{3U};
#else
constexpr const auto file_type_count{2U};
constexpr auto file_type_count{2U};
#endif
[[nodiscard]] auto create_file(auto idx, auto path, bool read_only = false)