From 9119de3a643f8adf2c4a12587e32577caa762b5a Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 12 Aug 2022 16:10:21 +0200 Subject: Fix build with gcc/g++ --- src/buildtool/execution_api/remote/config.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/buildtool/execution_api/remote/config.hpp') diff --git a/src/buildtool/execution_api/remote/config.hpp b/src/buildtool/execution_api/remote/config.hpp index 14995b89..cf1fd3ee 100644 --- a/src/buildtool/execution_api/remote/config.hpp +++ b/src/buildtool/execution_api/remote/config.hpp @@ -1,6 +1,7 @@ #ifndef INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_CONFIG_HPP #define INCLUDED_SRC_BUILDTOOL_EXECUTION_API_REMOTE_CONFIG_HPP +#include #include #include #include @@ -12,12 +13,17 @@ #include "gsl-lite/gsl-lite.hpp" #include "src/buildtool/logging/logger.hpp" +#include "src/utils/cpp/type_safe_arithmetic.hpp" + +// Port +struct PortTag : type_safe_arithmetic_tag {}; +using Port = type_safe_arithmetic; class RemoteExecutionConfig { public: struct ServerAddress { std::string host{}; - int port{}; + Port port{}; }; // Obtain global instance @@ -94,7 +100,8 @@ class RemoteExecutionConfig { auto port_num = std::stoi(port); if (not host.empty() and port_num >= 0 and port_num <= kMaxPortNumber) { - return ServerAddress{std::move(host), port_num}; + return ServerAddress{std::move(host), + gsl::narrow_cast(port_num)}; } } catch (std::out_of_range const& e) { Logger::Log(LogLevel::Error, "Port raised out_of_range exception."); -- cgit v1.2.3