Clean up part 4.
This commit is contained in:
parent
2ac14d0cab
commit
fa913a9986
@ -60,5 +60,5 @@ struct streams
|
||||
|
||||
inline std::ostream& streams::cout = std::cout;
|
||||
inline std::ostream& streams::cerr = std::cerr;
|
||||
inline osyncstream sscout(streams::cout);
|
||||
inline osyncstream sscerr(streams::cerr);
|
||||
[[maybe_unused]] inline osyncstream sscout(streams::cout); // NOLINT(cert-err58-cpp)
|
||||
[[maybe_unused]] inline osyncstream sscerr(streams::cerr); // NOLINT(cert-err58-cpp)
|
@ -10,13 +10,13 @@ constexpr auto all = std::numeric_limits<std::streamsize>::max();
|
||||
|
||||
namespace math
|
||||
{
|
||||
template<auto lb, typeof(lb) ub, std::enable_if_t<std::is_integral<typeof(lb)>::value, bool> = true>
|
||||
template<auto lb, typeof(lb) ub> [[maybe_unused]]
|
||||
constexpr auto is_between(typeof(lb) x) -> bool { return (ub > x) && (x > lb); }
|
||||
template<auto lb, std::enable_if_t<std::is_integral<typeof(lb)>::value, bool> = true>
|
||||
template<auto lb> [[maybe_unused]]
|
||||
constexpr auto is_larger(typeof(lb) x) -> bool { return (x > lb); }
|
||||
template<auto ub, std::enable_if_t<std::is_integral<typeof(ub)>::value, bool> = true>
|
||||
template<auto ub> [[maybe_unused]]
|
||||
constexpr auto is_smaller(typeof(ub) x) -> bool { return (ub > x); }
|
||||
template<typename T, std::enable_if_t<std::is_integral<typeof(T)>::value, bool> = true>
|
||||
template<typename T> [[maybe_unused]]
|
||||
auto numerical_suffix(T value) -> std::string
|
||||
{
|
||||
std::string suffixes[4] = {"th", "st", "nd", "rd"};
|
||||
@ -30,7 +30,7 @@ namespace math
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename T> [[maybe_unused]]
|
||||
T get_input(const std::string& prompt, const std::string& on_error, std::function<bool(T)> validator) noexcept
|
||||
{
|
||||
T user_input{};
|
||||
@ -54,5 +54,5 @@ T get_input(const std::string& prompt, const std::string& on_error, std::functio
|
||||
catch (std::exception&) { return user_input; } /* This should not happen ..... cin/cout are not configured to throw...*/
|
||||
}
|
||||
struct always_true_validator { template<typename T> bool operator()(T) const { return true; }};
|
||||
template<typename T>
|
||||
template<typename T> [[maybe_unused]]
|
||||
T get_input(const std::string& prompt) { return get_input<T>(prompt, "", always_true_validator()); }
|
5
main.cpp
5
main.cpp
@ -1,14 +1,11 @@
|
||||
#if WIN32
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include "modernize/sockets.h"
|
||||
#include "libraries/user_input.h"
|
||||
#include "libraries/osyncstream.h"
|
||||
#include "libraries/terminal.h"
|
||||
#include "libraries/json.hpp"
|
||||
#include <chrono>
|
||||
#include "project/server.h"
|
||||
#include "project/client.h"
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
::getaddrinfo(address.c_str(), port.c_str(), &hints, &result);
|
||||
::getaddrinfo(address.c_str(), port.c_str(), &hints, &result); // NOLINT(bugprone-unused-return-value)
|
||||
return addrinfo_up(result);
|
||||
}
|
||||
static auto listen(const SOCKET socket) noexcept -> int { return ::listen(socket, SOMAXCONN); }
|
||||
@ -52,7 +52,7 @@ public:
|
||||
/* extern functions */
|
||||
static void prologue() noexcept;
|
||||
static void epilogue() noexcept;
|
||||
static auto closesocket(const SOCKET socket) noexcept -> unsigned;
|
||||
static auto closesocket(SOCKET socket) noexcept -> unsigned;
|
||||
static auto recv(SOCKET socket) noexcept -> std::string;
|
||||
static auto system(const std::string& command) noexcept -> std::string;
|
||||
|
||||
|
@ -3,6 +3,5 @@
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#define SOCKET_ERROR -1
|
||||
#define INVALID_SOCKET 0
|
||||
typedef int SOCKET;
|
Loading…
Reference in New Issue
Block a user