Commit 59bf642e authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Merge branch '108-use-c-20' into 'main'

Resolve "Use C++20"

Closes #108

See merge request !73
parents 46def9d4 fe1abb5e
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ set(CMAKE_SHARED_LINKER_FLAGS_ASAN
set_property(GLOBAL APPEND PROPERTY DEBUG_CONFIGURATIONS Debug)
set_property(GLOBAL APPEND PROPERTY DEBUG_CONFIGURATIONS ASan)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

message(STATUS "[${PROJECT_NAME}] Project version: ${PROJECT_VERSION}")
@@ -220,7 +220,7 @@ message(STATUS "[${PROJECT_NAME}] Downloading and building file_options")
FetchContent_Declare(
  file_options
  GIT_REPOSITORY https://storage.bsc.es/gitlab/utils/file_options
  GIT_TAG 50071ff78d0974b2f1178f27ce1a08d22e5e8fa2 # v0.1.0-pre
  GIT_TAG bdb4f7f7f2dd731815241fc41afe6373df8f732a # v0.1.0-pre
  GIT_SHALLOW ON
  GIT_PROGRESS ON
)
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ prepare_datasets(const std::string& pattern, size_t n) {
    std::vector<admire::dataset> datasets;
    datasets.reserve(n);
    for(size_t i = 0; i < n; ++i) {
        datasets.emplace_back(fmt::format(pattern, i));
        datasets.emplace_back(fmt::format(fmt::runtime(pattern), i));
    }

    return datasets;
+16 −14
Original line number Diff line number Diff line
@@ -161,26 +161,26 @@ public:

    template <typename... Args>
    inline void
    info(const char* fmt, const Args&... args) {
        m_internal_logger->info(fmt, args...);
    info(fmt::format_string<Args...> fmt, Args&&... args) {
        m_internal_logger->info(fmt, std::forward<Args>(args)...);
    }

    template <typename... Args>
    inline void
    debug(const char* fmt, const Args&... args) {
        m_internal_logger->debug(fmt, args...);
    debug(fmt::format_string<Args...> fmt, Args&&... args) {
        m_internal_logger->debug(fmt, std::forward<Args>(args)...);
    }

    template <typename... Args>
    inline void
    warn(const char* fmt, const Args&... args) {
        m_internal_logger->warn(fmt, args...);
    warn(fmt::format_string<Args...> fmt, Args&&... args) {
        m_internal_logger->warn(fmt, std::forward<Args>(args)...);
    }

    template <typename... Args>
    inline void
    error(const char* fmt, const Args&... args) {
        m_internal_logger->error(fmt, args...);
    error(fmt::format_string<Args...> fmt, Args&&... args) {
        m_internal_logger->error(fmt, std::forward<Args>(args)...);
    }

    static inline std::string
@@ -194,25 +194,27 @@ public:

    template <typename... Args>
    inline void
    error_errno(const char* fmt, const Args&... args) {
    error_errno(fmt::format_string<Args...> fmt, Args&&... args) {

        const int saved_errno = errno;

        constexpr const std::size_t MAX_ERROR_MSG = 128;
        std::array<char, MAX_ERROR_MSG> errstr;
        std::array<char, MAX_ERROR_MSG> errstr; // NOLINT

        std::string str_fmt(fmt);
        fmt::string_view sv{fmt};
        std::string str_fmt{sv.begin(), sv.end()};
        str_fmt += ": {}";

        char* msg = strerror_r(saved_errno, errstr.data(), MAX_ERROR_MSG);

        m_internal_logger->error(str_fmt.c_str(), args..., msg);
        m_internal_logger->error(fmt::runtime(str_fmt),
                                 std::forward<Args>(args)..., msg);
    }

    template <typename... Args>
    inline void
    critical(const char* fmt, const Args&... args) {
        m_internal_logger->critical(fmt, args...);
    critical(fmt::format_string<Args...> fmt, Args&&... args) {
        m_internal_logger->critical(fmt, std::forward<Args>(args)...);
    }

    template <typename T>
+12 −18
Original line number Diff line number Diff line
@@ -296,15 +296,12 @@ server::check_configuration() {

void
server::print_greeting() {
    const char greeting[] = "Starting {} daemon (pid {})";
    const auto gsep =
            std::string(sizeof(greeting) - 4 + m_settings->progname().size() +
                                std::to_string(getpid()).size(),
                        '=');
    const auto greeting = fmt::format("Starting {} daemon (pid {})",
                                      m_settings->progname(), getpid());

    LOGGER_INFO("{}", gsep);
    LOGGER_INFO(greeting, m_settings->progname(), getpid());
    LOGGER_INFO("{}", gsep);
    LOGGER_INFO("{:=>{}}", "", greeting.size());
    LOGGER_INFO(greeting);
    LOGGER_INFO("{:=>{}}", "", greeting.size());
}

void
@@ -332,15 +329,12 @@ server::print_configuration() {

void
server::print_farewell() {
    const char farewell[] = "Stopping {} daemon (pid {})";
    const auto fsep =
            std::string(sizeof(farewell) - 4 + m_settings->progname().size() +
                                std::to_string(getpid()).size(),
                        '=');

    LOGGER_INFO("{}", fsep);
    LOGGER_INFO(farewell, m_settings->progname(), getpid());
    LOGGER_INFO("{}", fsep);
    const auto farewell = fmt::format("Stopping {} daemon (pid {})",
                                      m_settings->progname(), getpid());

    LOGGER_INFO("{:=>{}}", "", farewell.size());
    LOGGER_INFO(farewell);
    LOGGER_INFO("{:=>{}}", "", farewell.size());
}

int
+4 −3
Original line number Diff line number Diff line
@@ -366,9 +366,9 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) {
    auto endp = rpc_client.lookup(srv.address());

    LOGGER_INFO("rpc id: {} name: {} from: {} => "
                "body: {{adhoc_storage: {}}}",
                "body: {{adhoc_id: {}}}",
                rpc_id, std::quoted("ADM_"s + __FUNCTION__),
                std::quoted(rpc_client.self_address()), adhoc_storage);
                std::quoted(rpc_client.self_address()), adhoc_storage.id());

    ADM_deploy_adhoc_storage_in_t in{adhoc_storage.id()};
    ADM_deploy_adhoc_storage_out_t out;
@@ -384,8 +384,9 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) {
    }

    LOGGER_INFO("rpc id: {} name: {} from: {} <= "
                "body: {{retval: {}}}] [op_id: {}]",
                "body: {{retval: {}}} [op_id: {}]",
                rpc_id, std::quoted("ADM_"s + __FUNCTION__),
                std::quoted(rpc_client.self_address()),
                admire::error_code::success, out.op_id);

    return admire::error_code::success;
Loading