diff --git a/include/Common.h b/include/Common.h index 7759e43..a6aea21 100644 --- a/include/Common.h +++ b/include/Common.h @@ -132,6 +132,10 @@ private: static inline Version mVersion { 3, 9, 2 }; }; +/// Used to static_assert in std::visit +template +inline constexpr bool AlwaysFalseV = false; + void SplitString(std::string const& str, const char delim, std::vector& out); std::string LowerString(std::string str); diff --git a/src/Common.cpp b/src/Common.cpp index 7fff4c6..a20141f 100644 --- a/src/Common.cpp +++ b/src/Common.cpp @@ -378,7 +378,7 @@ std::ostream& operator<<(std::ostream& os, const TDetachedLuaValue& value) { std::visit([&os](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v>) { + if constexpr (std::is_same_v) { size_t i = 0; for (auto val : arg) { if (i > 0) { @@ -386,7 +386,7 @@ std::ostream& operator<<(std::ostream& os, const TDetachedLuaValue& value) { } os << val; } - } else if constexpr (std::is_same_v>) { + } else if constexpr (std::is_same_v) { size_t i = 0; for (auto [key, val] : arg) { if (i > 0) { @@ -406,7 +406,7 @@ std::ostream& operator<<(std::ostream& os, const TDetachedLuaValue& value) { // monostate means no result value os << ""; else - static_assert(false, "non-exhaustive visitor!"); + static_assert(AlwaysFalseV, "non-exhaustive visitor!"); }, value.V); diff --git a/src/TLuaEngine.cpp b/src/TLuaEngine.cpp index eddff6f..84dd501 100644 --- a/src/TLuaEngine.cpp +++ b/src/TLuaEngine.cpp @@ -570,7 +570,7 @@ sol::table TLuaEngine::StateThreadData::Lua_TriggerGlobalEvent(const std::string // monostate means no result value Result.set(i, sol::lua_nil_t()); else - static_assert(false, "non-exhaustive visitor!"); + static_assert(AlwaysFalseV, "non-exhaustive visitor!"); }, Snapshot.Result.V); } @@ -1259,7 +1259,7 @@ void TLuaEngine::StateThreadData::operator()() { } else if constexpr (std::is_same_v) { LuaArgs.push_back(sol::make_object(StateView, arg)); } else { - static_assert(false, "unhandled variant"); + static_assert(AlwaysFalseV, "unhandled variant"); } }, Arg); }