diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-08-12 16:10:21 +0200 |
---|---|---|
committer | Oliver Reiche <oliver.reiche@huawei.com> | 2022-09-13 10:51:13 +0200 |
commit | 9119de3a643f8adf2c4a12587e32577caa762b5a (patch) | |
tree | d1e01b98770002d5a27b0d95e317817fbf2eac40 /src/buildtool/execution_api/remote/config.hpp | |
parent | 693173e3b0ff9ddf3018e42b4e880f5aa18a978a (diff) | |
download | justbuild-9119de3a643f8adf2c4a12587e32577caa762b5a.tar.gz |
Fix build with gcc/g++
Diffstat (limited to 'src/buildtool/execution_api/remote/config.hpp')
-rw-r--r-- | src/buildtool/execution_api/remote/config.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
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 <cstdint> #include <map> #include <memory> #include <optional> @@ -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<std::uint16_t> {}; +using Port = type_safe_arithmetic<PortTag>; 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::value_t>(port_num)}; } } catch (std::out_of_range const& e) { Logger::Log(LogLevel::Error, "Port raised out_of_range exception."); |