From 0a81206b7e2eb8c192f9437008bdf9748bc2faaa Mon Sep 17 00:00:00 2001 From: Nicolas Hake Date: Tue, 1 Jan 2019 21:33:32 +0100 Subject: [PATCH] C4Property: Remove raw operator void* operator void* is a quick and dirty workaround for the lack of explicit operator bool in old C++ standards. Since we can use explicit operator bool now, we don't need the operator void* anymore. Incidentally, that operator also allowed C4Set to equality compare C4Property entries, which is unintuitive. Replace it with an explicit specialization of C4Set::Equals. --- src/script/C4PropList.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/script/C4PropList.h b/src/script/C4PropList.h index 020811fd0..b5c7e77b1 100644 --- a/src/script/C4PropList.h +++ b/src/script/C4PropList.h @@ -1,7 +1,7 @@ /* * OpenClonk, http://www.openclonk.org * - * Copyright (c) 2009-2016, The OpenClonk Team and contributors + * Copyright (c) 2009-2019, The OpenClonk Team and contributors * * Distributed under the terms of the ISC license; see accompanying file * "COPYING" for details. @@ -53,10 +53,16 @@ public: void CompileFunc(StdCompiler *pComp, C4ValueNumbers *); C4String * Key{nullptr}; C4Value Value; - operator const void * () const { return Key; } + explicit operator bool() const { return Key != nullptr; } bool operator < (const C4Property &cmp) const { return strcmp(GetSafeKey(), cmp.GetSafeKey())<0; } const char *GetSafeKey() const { if (Key && Key->GetCStr()) return Key->GetCStr(); return ""; } // get key as C string; return "" if undefined. never return nullptr }; + +inline bool C4Set::Equals(const C4Property &a, const C4Property &b) +{ + return a.Key == b.Key; +} + class C4PropListNumbered; class C4PropList {