Core/Misc: Fix build with libc++

Closes #28909
This commit is contained in:
Shauren
2023-04-10 00:08:32 +02:00
parent 9c367e2f21
commit 083b8d6c84
5 changed files with 23 additions and 10 deletions

View File

@@ -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}")

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}