Merge pull request #604 from AbigailBuccaneer/gcc6-unique-ptr

Use std::unique_ptr correctly across compiler and language versions
This commit is contained in:
Christopher Dunn 2017-04-23 01:12:31 -05:00 committed by GitHub
commit 3cde9a9912
3 changed files with 14 additions and 4 deletions

View File

@ -51,6 +51,16 @@
#define JSON_API
#endif
#if !defined(JSON_HAS_UNIQUE_PTR)
#if __cplusplus >= 201103L
#define JSON_HAS_UNIQUE_PTR (1)
#elif _MSC_VER >= 1600
#define JSON_HAS_UNIQUE_PTR (1)
#else
#define JSON_HAS_UNIQUE_PTR (0)
#endif
#endif
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
// integer
// Storages, and 64 bits integer support is disabled.

View File

@ -43,8 +43,8 @@ static int stackDepth_g = 0; // see readValue()
namespace Json {
#if __GNUC__ >= 6
typedef std::scoped_ptr<CharReader> const CharReaderPtr;
#if JSON_HAS_UNIQUE_PTR
typedef std::unique_ptr<CharReader> const CharReaderPtr;
#else
typedef std::auto_ptr<CharReader> CharReaderPtr;
#endif

View File

@ -54,8 +54,8 @@
namespace Json {
#if __GNUC__ >= 6
typedef std::scoped_ptr<StreamWriter> const StreamWriterPtr;
#if JSON_HAS_UNIQUE_PTR
typedef std::unique_ptr<StreamWriter> const StreamWriterPtr;
#else
typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
#endif