Skip to content

Commit 3cde9a9

Browse files
authored
Merge pull request #604 from AbigailBuccaneer/gcc6-unique-ptr
Use std::unique_ptr correctly across compiler and language versions
2 parents 3eda8a6 + 347e1ae commit 3cde9a9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

include/json/config.h

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
#define JSON_API
5252
#endif
5353

54+
#if !defined(JSON_HAS_UNIQUE_PTR)
55+
#if __cplusplus >= 201103L
56+
#define JSON_HAS_UNIQUE_PTR (1)
57+
#elif _MSC_VER >= 1600
58+
#define JSON_HAS_UNIQUE_PTR (1)
59+
#else
60+
#define JSON_HAS_UNIQUE_PTR (0)
61+
#endif
62+
#endif
63+
5464
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
5565
// integer
5666
// Storages, and 64 bits integer support is disabled.

src/lib_json/json_reader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static int stackDepth_g = 0; // see readValue()
4343

4444
namespace Json {
4545

46-
#if __GNUC__ >= 6
47-
typedef std::scoped_ptr<CharReader> const CharReaderPtr;
46+
#if JSON_HAS_UNIQUE_PTR
47+
typedef std::unique_ptr<CharReader> const CharReaderPtr;
4848
#else
4949
typedef std::auto_ptr<CharReader> CharReaderPtr;
5050
#endif

src/lib_json/json_writer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454

5555
namespace Json {
5656

57-
#if __GNUC__ >= 6
58-
typedef std::scoped_ptr<StreamWriter> const StreamWriterPtr;
57+
#if JSON_HAS_UNIQUE_PTR
58+
typedef std::unique_ptr<StreamWriter> const StreamWriterPtr;
5959
#else
6060
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
6161
#endif

0 commit comments

Comments
 (0)