diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-04-10 00:08:32 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-04-10 00:08:32 +0200 |
commit | 083b8d6c846cfdf75abb1fae481a3eeb25c13c56 (patch) | |
tree | 332ad0b73ee8f4ea1f9bc75d1018d09a473bc60f | |
parent | 9c367e2f21f5ce3859e5e7032fb8d564fe1b3bf4 (diff) |
Core/Misc: Fix build with libc++
Closes #28909
-rw-r--r-- | cmake/compiler/clang/settings.cmake | 5 | ||||
-rw-r--r-- | src/common/Utilities/advstd.h | 5 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 11 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 7 | ||||
-rw-r--r-- | src/server/game/Entities/Object/ObjectGuid.h | 5 |
5 files changed, 23 insertions, 10 deletions
diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake index f6e95030b57..6cfc8ff30aa 100644 --- a/cmake/compiler/clang/settings.cmake +++ b/cmake/compiler/clang/settings.cmake @@ -6,6 +6,11 @@ target_compile_definitions(trinity-compile-option-interface -D_BUILD_DIRECTIVE="$<CONFIG>") set(CLANG_EXPECTED_VERSION 11.0.0) +if(CMAKE_CXX_COMPILER MATCHES "Clang") + # apple doesnt like to do the sane thing which would be to use the same version numbering as regular clang + # version number pulled from https://en.wikipedia.org/wiki/Xcode#Toolchain_versions for row matching LLVM 11 + set(CLANG_EXPECTED_VERSION 12.0.5) +endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_EXPECTED_VERSION) message(FATAL_ERROR "Clang: TrinityCore requires version ${CLANG_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}") diff --git a/src/common/Utilities/advstd.h b/src/common/Utilities/advstd.h index ff2717c9755..5b9991854bf 100644 --- a/src/common/Utilities/advstd.h +++ b/src/common/Utilities/advstd.h @@ -18,9 +18,14 @@ #ifndef TRINITY_ADVSTD_H #define TRINITY_ADVSTD_H +#include <compare> + // this namespace holds implementations of upcoming stdlib features that our c++ version doesn't have yet namespace advstd { +// libc++ is missing these two +[[nodiscard]] constexpr bool is_eq(std::partial_ordering cmp) noexcept { return cmp == 0; } +[[nodiscard]] constexpr bool is_neq(std::partial_ordering cmp) noexcept { return cmp != 0; } } #endif diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 31bb3c82161..9406fbedb00 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -21,6 +21,7 @@ #include "Define.h" #include "ObjectGuid.h" #include "WaypointDefines.h" +#include "advstd.h" #include <limits> #include <map> #include <string> @@ -1645,15 +1646,15 @@ struct SmartScriptHolder // Default comparision operator using priority field as first ordering field std::strong_ordering operator<=>(SmartScriptHolder const& right) const { - if (auto cmp = priority <=> right.priority; std::is_neq(cmp)) + if (std::strong_ordering cmp = priority <=> right.priority; advstd::is_neq(cmp)) return cmp; - if (auto cmp = entryOrGuid <=> right.entryOrGuid; std::is_neq(cmp)) + if (std::strong_ordering cmp = entryOrGuid <=> right.entryOrGuid; advstd::is_neq(cmp)) return cmp; - if (auto cmp = source_type <=> right.source_type; std::is_neq(cmp)) + if (std::strong_ordering cmp = source_type <=> right.source_type; advstd::is_neq(cmp)) return cmp; - if (auto cmp = event_id <=> right.event_id; std::is_neq(cmp)) + if (std::strong_ordering cmp = event_id <=> right.event_id; advstd::is_neq(cmp)) return cmp; - if (auto cmp = link <=> right.link; std::is_neq(cmp)) + if (std::strong_ordering cmp = link <=> right.link; advstd::is_neq(cmp)) return cmp; return std::strong_ordering::equal; } diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 704fc872034..314556b8239 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -22,6 +22,7 @@ #include "DB2Structure.h" #include "Optional.h" #include "SharedDefines.h" +#include "advstd.h" #include <map> #include <set> #include <vector> @@ -352,11 +353,11 @@ public: friend std::strong_ordering operator<=>(HotfixRecord const& left, HotfixRecord const& right) { - if (auto cmp = left.ID <=> right.ID; std::is_neq(cmp)) + if (std::strong_ordering cmp = left.ID <=> right.ID; advstd::is_neq(cmp)) return cmp; - if (auto cmp = left.TableHash <=> right.TableHash; std::is_neq(cmp)) + if (std::strong_ordering cmp = left.TableHash <=> right.TableHash; advstd::is_neq(cmp)) return cmp; - if (auto cmp = left.RecordID <=> right.RecordID; std::is_neq(cmp)) + if (std::strong_ordering cmp = left.RecordID <=> right.RecordID; advstd::is_neq(cmp)) return cmp; return std::strong_ordering::equal; } diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h index 5affc9b0255..b3a0213436d 100644 --- a/src/server/game/Entities/Object/ObjectGuid.h +++ b/src/server/game/Entities/Object/ObjectGuid.h @@ -20,6 +20,7 @@ #include "Define.h" #include "EnumFlag.h" +#include "advstd.h" #include <array> #include <functional> #include <list> @@ -333,9 +334,9 @@ class TC_GAME_API ObjectGuid bool operator==(ObjectGuid const& right) const = default; std::strong_ordering operator<=>(ObjectGuid const& right) const { - if (std::strong_ordering cmp = _data[1] <=> right._data[1]; std::is_neq(cmp)) + if (std::strong_ordering cmp = _data[1] <=> right._data[1]; advstd::is_neq(cmp)) return cmp; - if (std::strong_ordering cmp = _data[0] <=> right._data[0]; std::is_neq(cmp)) + if (std::strong_ordering cmp = _data[0] <=> right._data[0]; advstd::is_neq(cmp)) return cmp; return std::strong_ordering::equal; } |