diff --git a/Source/engine.h b/Source/engine.h index 6750e6c62..23cd804f7 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -43,7 +43,6 @@ namespace devilution { -#if __cplusplus >= 201703L template constexpr bool IsAnyOf(const V &v, X x, Xs... xs) { @@ -55,31 +54,6 @@ constexpr bool IsNoneOf(const V &v, X x, Xs... xs) { return v != x && ((v != xs) && ...); } -#else -template -constexpr bool IsAnyOf(const V &v, X x) -{ - return v == x; -} - -template -constexpr bool IsAnyOf(const V &v, X x, Xs... xs) -{ - return IsAnyOf(v, x) || IsAnyOf(v, xs...); -} - -template -constexpr bool IsNoneOf(const V &v, X x) -{ - return v != x; -} - -template -constexpr bool IsNoneOf(const V &v, X x, Xs... xs) -{ - return IsNoneOf(v, x) && IsNoneOf(v, xs...); -} -#endif /** * @brief Draw a horizontal line segment in the target buffer (left to right) diff --git a/Source/utils/static_vector.hpp b/Source/utils/static_vector.hpp index a4874dfb3..a10745983 100644 --- a/Source/utils/static_vector.hpp +++ b/Source/utils/static_vector.hpp @@ -73,11 +73,7 @@ public: ~StaticVector() { for (std::size_t pos = 0; pos < size_; ++pos) { -#if __cplusplus >= 201703L std::destroy_at(data_[pos].ptr()); -#else - data_[pos].ptr()->~T(); -#endif } } @@ -87,20 +83,12 @@ private: const T *ptr() const { -#if __cplusplus >= 201703L return std::launder(reinterpret_cast(data)); -#else - return reinterpret_cast(data); -#endif } T *ptr() { -#if __cplusplus >= 201703L return std::launder(reinterpret_cast(data)); -#else - return reinterpret_cast(data); -#endif } }; AlignedStorage data_[N]; diff --git a/Source/utils/stdcompat/abs.hpp b/Source/utils/stdcompat/abs.hpp index eaf350cc6..da4106b6c 100644 --- a/Source/utils/stdcompat/abs.hpp +++ b/Source/utils/stdcompat/abs.hpp @@ -3,15 +3,5 @@ #include namespace devilution { - -template -constexpr T abs(const T &a) -{ -#if defined(__GNUC__) || defined(__GNUG__) || defined(_MSC_VER) - return std::abs(a); -#else - return (a < 0) ? -a : a; -#endif -} - +using ::std::abs; } // namespace devilution diff --git a/Source/utils/stdcompat/algorithm.hpp b/Source/utils/stdcompat/algorithm.hpp index acf315cfe..7c29d8b69 100644 --- a/Source/utils/stdcompat/algorithm.hpp +++ b/Source/utils/stdcompat/algorithm.hpp @@ -3,13 +3,5 @@ #include // IWYU pragma: export namespace devilution { -#if defined(__cplusplus) && __cplusplus >= 201703L -using std::clamp; // NOLINT(misc-unused-using-decls) -#else -template -constexpr const T &clamp(const T &x, const T &lower, const T &upper) -{ - return std::min(std::max(x, lower), upper); -} -#endif +using ::std::clamp; } // namespace devilution diff --git a/Source/utils/stdcompat/cstddef.hpp b/Source/utils/stdcompat/cstddef.hpp index fead367b8..6bd176dea 100644 --- a/Source/utils/stdcompat/cstddef.hpp +++ b/Source/utils/stdcompat/cstddef.hpp @@ -2,13 +2,6 @@ #include // IWYU pragma: export -#if defined(__cplusplus) && __cplusplus >= 201703L namespace devilution { -using byte = std::byte; -} // namespace devilution -#else -#include -namespace devilution { -using byte = std::uint8_t; -} // namespace devilution -#endif +using ::std::byte; +} diff --git a/Source/utils/stdcompat/invoke_result_t.hpp b/Source/utils/stdcompat/invoke_result_t.hpp index 06480a688..7d0535cff 100644 --- a/Source/utils/stdcompat/invoke_result_t.hpp +++ b/Source/utils/stdcompat/invoke_result_t.hpp @@ -1,14 +1,7 @@ -#pragma once - -#include - -namespace devilution { - -#if defined(__cplusplus) && __cplusplus >= 201703L -using std::invoke_result_t; -#else -template -using invoke_result_t = typename std::result_of::type; -#endif - -} // namespace devilution +#pragma once + +#include + +namespace devilution { +using ::std::invoke_result_t; +} // namespace devilution diff --git a/Source/utils/stdcompat/optional.hpp b/Source/utils/stdcompat/optional.hpp index 90af7a275..0b2bfe323 100644 --- a/Source/utils/stdcompat/optional.hpp +++ b/Source/utils/stdcompat/optional.hpp @@ -1,16 +1,3 @@ #pragma once -#ifdef __has_include -#if defined(__cplusplus) && (__cplusplus >= 201606L || _MSC_VER >= 1930) && __has_include() #include // IWYU pragma: export -#elif __has_include() -#include // IWYU pragma: export -#define optional experimental::optional -#define nullopt experimental::nullopt -#define nullopt_t experimental::nullopt_t -#else -#error "Missing support for or " -#endif -#else -#error "__has_include unavailable" -#endif diff --git a/Source/utils/stdcompat/string_view.hpp b/Source/utils/stdcompat/string_view.hpp index b6e901a84..170d017db 100644 --- a/Source/utils/stdcompat/string_view.hpp +++ b/Source/utils/stdcompat/string_view.hpp @@ -1,34 +1,12 @@ #pragma once -#ifdef __has_include -#if defined(__cplusplus) && (__cplusplus >= 201703L || _MSC_VER >= 1930) && __has_include() // should be 201606L, but STL headers disagree - #include #include // IWYU pragma: export namespace devilution { -using string_view = std::string_view; +using ::std::string_view; inline void AppendStrView(std::string &out, string_view str) { out.append(str); } } // namespace devilution -#elif __has_include() - -#include // IWYU pragma: export -namespace devilution { -using string_view = std::experimental::string_view; - -inline void AppendStrView(std::string &out, string_view str) -{ - out.append(str.data(), str.size()); -} -} // namespace devilution -#else - -#error "Missing support for or " -#endif -#else - -#error "__has_include unavailable" -#endif diff --git a/Source/utils/str_cat.hpp b/Source/utils/str_cat.hpp index b37d2e035..fbd71b9ec 100644 --- a/Source/utils/str_cat.hpp +++ b/Source/utils/str_cat.hpp @@ -54,38 +54,19 @@ inline void StrAppend(std::string &out, const char *str) AppendStrView(out, string_view(str != nullptr ? str : "(nullptr)")); } -#if __cplusplus >= 201703L template typename std::enable_if<(sizeof...(Args) > 1), char *>::type BufCopy(char *out, Args &&...args) { return ((out = BufCopy(out, std::forward(args))), ...); } -#else -template -inline typename std::enable_if<(sizeof...(Args) > 0), char *>::type -BufCopy(char *out, Arg &&arg, Args &&...args) -{ - return BufCopy(BufCopy(out, std::forward(arg)), std::forward(args)...); -} -#endif -#if __cplusplus >= 201703L template typename std::enable_if<(sizeof...(Args) > 1), void>::type StrAppend(std::string &out, Args &&...args) { (StrAppend(out, std::forward(args)), ...); } -#else -template -typename std::enable_if<(sizeof...(Args) > 0), void>::type -StrAppend(std::string &out, Arg &&arg, Args &&...args) -{ - StrAppend(out, std::forward(arg)); - StrAppend(out, std::forward(args)...); -} -#endif template std::string StrCat(Args &&...args)