Run Clang-tidy with modernize-use-auto (#1077)
* Run clang-tidy modify with modernize-use-auto
* Use using instead of typedef
diff --git a/include/json/config.h b/include/json/config.h
index 0a3bc92..3d148a6 100644
--- a/include/json/config.h
+++ b/include/json/config.h
@@ -119,23 +119,23 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
-typedef int Int;
-typedef unsigned int UInt;
+using Int = int;
+using UInt = unsigned int;
#if defined(JSON_NO_INT64)
-typedef int LargestInt;
-typedef unsigned int LargestUInt;
+using LargestInt = int;
+using LargestUInt = unsigned int;
#undef JSON_HAS_INT64
#else // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
-typedef __int64 Int64;
-typedef unsigned __int64 UInt64;
+using Int64 = __int64;
+using UInt64 = unsigned __int64;
#else // if defined(_MSC_VER) // Other platforms, use long long
-typedef int64_t Int64;
-typedef uint64_t UInt64;
+using Int64 = int64_t;
+using UInt64 = uint64_t;
#endif // if defined(_MSC_VER)
-typedef Int64 LargestInt;
-typedef UInt64 LargestUInt;
+using LargestInt = Int64;
+using LargestUInt = UInt64;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
diff --git a/include/json/forwards.h b/include/json/forwards.h
index b0d981b..affe33a 100644
--- a/include/json/forwards.h
+++ b/include/json/forwards.h
@@ -29,7 +29,7 @@
class Features;
// value.h
-typedef unsigned int ArrayIndex;
+using ArrayIndex = unsigned int;
class StaticString;
class Path;
class PathArgument;
diff --git a/include/json/reader.h b/include/json/reader.h
index 1540ac3..9175466 100644
--- a/include/json/reader.h
+++ b/include/json/reader.h
@@ -36,8 +36,8 @@
class JSONCPP_DEPRECATED(
"Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
public:
- typedef char Char;
- typedef const Char* Location;
+ using Char = char;
+ using Location = const Char*;
/** \brief An error tagged with where in the JSON text it was encountered.
*
@@ -187,7 +187,7 @@
Location extra_;
};
- typedef std::deque<ErrorInfo> Errors;
+ using Errors = std::deque<ErrorInfo>;
bool readToken(Token& token);
void skipSpaces();
@@ -226,7 +226,7 @@
static bool containsNewLine(Location begin, Location end);
static String normalizeEOL(Location begin, Location end);
- typedef std::stack<Value*> Nodes;
+ using Nodes = std::stack<Value*>;
Nodes nodes_;
Errors errors_;
String document_;
diff --git a/include/json/value.h b/include/json/value.h
index c4b29b9..e169c3c 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -176,21 +176,21 @@
friend class ValueIteratorBase;
public:
- typedef std::vector<String> Members;
- typedef ValueIterator iterator;
- typedef ValueConstIterator const_iterator;
- typedef Json::UInt UInt;
- typedef Json::Int Int;
+ using Members = std::vector<String>;
+ using iterator = ValueIterator;
+ using const_iterator = ValueConstIterator;
+ using UInt = Json::UInt;
+ using Int = Json::Int;
#if defined(JSON_HAS_INT64)
- typedef Json::UInt64 UInt64;
- typedef Json::Int64 Int64;
+ using UInt64 = Json::UInt64;
+ using Int64 = Json::Int64;
#endif // defined(JSON_HAS_INT64)
- typedef Json::LargestInt LargestInt;
- typedef Json::LargestUInt LargestUInt;
- typedef Json::ArrayIndex ArrayIndex;
+ using LargestInt = Json::LargestInt;
+ using LargestUInt = Json::LargestUInt;
+ using ArrayIndex = Json::ArrayIndex;
// Required for boost integration, e. g. BOOST_TEST
- typedef std::string value_type;
+ using value_type = std::string;
#if JSON_USE_NULLREF
// Binary compatibility kludges, do not use.
@@ -710,8 +710,8 @@
Value& make(Value& root) const;
private:
- typedef std::vector<const PathArgument*> InArgs;
- typedef std::vector<PathArgument> Args;
+ using InArgs = std::vector<const PathArgument*>;
+ using Args = std::vector<PathArgument>;
void makePath(const String& path, const InArgs& in);
void addPathInArg(const String& path, const InArgs& in,
@@ -726,10 +726,10 @@
*/
class JSON_API ValueIteratorBase {
public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef unsigned int size_t;
- typedef int difference_type;
- typedef ValueIteratorBase SelfType;
+ using iterator_category = std::bidirectional_iterator_tag;
+ using size_t = unsigned int;
+ using difference_type = int;
+ using SelfType = ValueIteratorBase;
bool operator==(const SelfType& other) const { return isEqual(other); }
@@ -802,12 +802,12 @@
friend class Value;
public:
- typedef const Value value_type;
+ using value_type = const Value;
// typedef unsigned int size_t;
// typedef int difference_type;
- typedef const Value& reference;
- typedef const Value* pointer;
- typedef ValueConstIterator SelfType;
+ using reference = const Value&;
+ using pointer = const Value*;
+ using SelfType = ValueConstIterator;
ValueConstIterator();
ValueConstIterator(ValueIterator const& other);
@@ -853,12 +853,12 @@
friend class Value;
public:
- typedef Value value_type;
- typedef unsigned int size_t;
- typedef int difference_type;
- typedef Value& reference;
- typedef Value* pointer;
- typedef ValueIterator SelfType;
+ using value_type = Value;
+ using size_t = unsigned int;
+ using difference_type = int;
+ using reference = Value&;
+ using pointer = Value*;
+ using SelfType = ValueIterator;
ValueIterator();
explicit ValueIterator(const ValueConstIterator& other);
diff --git a/include/json/writer.h b/include/json/writer.h
index a72c06a..fb0852a 100644
--- a/include/json/writer.h
+++ b/include/json/writer.h
@@ -252,7 +252,7 @@
static bool hasCommentForValue(const Value& value);
static String normalizeEOL(const String& text);
- typedef std::vector<String> ChildValues;
+ using ChildValues = std::vector<String>;
ChildValues childValues_;
String document_;
@@ -326,7 +326,7 @@
static bool hasCommentForValue(const Value& value);
static String normalizeEOL(const String& text);
- typedef std::vector<String> ChildValues;
+ using ChildValues = std::vector<String>;
ChildValues childValues_;
OStream* document_;