From dc180eb25eca8d7ce16f062641e005e464ea398f Mon Sep 17 00:00:00 2001 From: David Gobbi Date: Thu, 13 Feb 2020 14:22:49 -0700 Subject: [PATCH] Remove '=delete' from template methods for Xcode 8 (#1133) For Apple clang-800.0.42.1, which was released with Xcode 8 in September 2016, the '=delete' on the 'is' and 'as' methods causes the following errors for value.h: inline declaration of 'as' follows non-inline definition inline declaration of 'is' follows non-inline definition etcetera for the other specializations of 'is' and 'as'. The same problem also occurs for clang-3.8 but not clang-3.9 or later. --- include/json/value.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index e169c3c..bea2a56 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -21,6 +21,24 @@ #endif #endif +// Support for '= delete' with template declarations was a late addition +// to the c++11 standard and is rejected by clang 3.8 and Apple clang 8.2 +// even though these declare themselves to be c++11 compilers. +#if !defined(JSONCPP_TEMPLATE_DELETE) +#if defined(__clang__) && defined(__apple_build_version__) +#if __apple_build_version__ <= 8000042 +#define JSONCPP_TEMPLATE_DELETE +#endif +#elif defined(__clang__) +#if __clang_major__ == 3 && __clang_minor__ <= 8 +#define JSONCPP_TEMPLATE_DELETE +#endif +#endif +#if !defined(JSONCPP_TEMPLATE_DELETE) +#define JSONCPP_TEMPLATE_DELETE = delete +#endif +#endif + #include #include #include @@ -390,8 +408,8 @@ public: bool isObject() const; /// The `as` and `is` member function templates and specializations. - template T as() const = delete; - template bool is() const = delete; + template T as() const JSONCPP_TEMPLATE_DELETE; + template bool is() const JSONCPP_TEMPLATE_DELETE; bool isConvertibleTo(ValueType other) const;