Skip to content

Commit dc180eb

Browse files
authored
Remove '=delete' from template methods for Xcode 8 (open-source-parsers#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<bool>' follows non-inline definition inline declaration of 'is<bool>' 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.
1 parent a6fe8e2 commit dc180eb

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

include/json/value.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121
#endif
2222
#endif
2323

24+
// Support for '= delete' with template declarations was a late addition
25+
// to the c++11 standard and is rejected by clang 3.8 and Apple clang 8.2
26+
// even though these declare themselves to be c++11 compilers.
27+
#if !defined(JSONCPP_TEMPLATE_DELETE)
28+
#if defined(__clang__) && defined(__apple_build_version__)
29+
#if __apple_build_version__ <= 8000042
30+
#define JSONCPP_TEMPLATE_DELETE
31+
#endif
32+
#elif defined(__clang__)
33+
#if __clang_major__ == 3 && __clang_minor__ <= 8
34+
#define JSONCPP_TEMPLATE_DELETE
35+
#endif
36+
#endif
37+
#if !defined(JSONCPP_TEMPLATE_DELETE)
38+
#define JSONCPP_TEMPLATE_DELETE = delete
39+
#endif
40+
#endif
41+
2442
#include <array>
2543
#include <exception>
2644
#include <map>
@@ -390,8 +408,8 @@ class JSON_API Value {
390408
bool isObject() const;
391409

392410
/// The `as<T>` and `is<T>` member function templates and specializations.
393-
template <typename T> T as() const = delete;
394-
template <typename T> bool is() const = delete;
411+
template <typename T> T as() const JSONCPP_TEMPLATE_DELETE;
412+
template <typename T> bool is() const JSONCPP_TEMPLATE_DELETE;
395413

396414
bool isConvertibleTo(ValueType other) const;
397415

0 commit comments

Comments
 (0)