Replace typedef with using

This commit is contained in:
Benoit Blanchon
2024-10-23 15:54:08 +02:00
parent 61ec2c4f95
commit c6c0649d70
30 changed files with 54 additions and 54 deletions

View File

@ -7,7 +7,7 @@
#include "Literals.hpp" #include "Literals.hpp"
typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy; using ElementProxy = ArduinoJson::detail::ElementProxy<JsonDocument&>;
TEST_CASE("ElementProxy::add()") { TEST_CASE("ElementProxy::add()") {
JsonDocument doc; JsonDocument doc;

View File

@ -14,8 +14,8 @@
using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofArray;
using ArduinoJson::detail::sizeofObject; using ArduinoJson::detail::sizeofObject;
typedef ArduinoJson::detail::MemberProxy<JsonDocument&, const char*> using MemberProxy =
MemberProxy; ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>;
TEST_CASE("MemberProxy::add()") { TEST_CASE("MemberProxy::add()") {
JsonDocument doc; JsonDocument doc;

View File

@ -99,7 +99,7 @@ TEST_CASE("vector<int>") {
} }
TEST_CASE("array<int, 2>") { TEST_CASE("array<int, 2>") {
typedef std::array<int, 2> array_type; using array_type = std::array<int, 2>;
SECTION("toJson") { SECTION("toJson") {
array_type v; array_type v;

View File

@ -8,4 +8,4 @@
struct custom_char_traits : std::char_traits<char> {}; struct custom_char_traits : std::char_traits<char> {};
typedef std::basic_string<char, custom_char_traits> custom_string; using custom_string = std::basic_string<char, custom_char_traits>;

View File

@ -17,7 +17,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
public: public:
typedef JsonArrayIterator iterator; using iterator = JsonArrayIterator;
// Constructs an unbound reference. // Constructs an unbound reference.
JsonArray() : data_(0), resources_(0) {} JsonArray() : data_(0), resources_(0) {}

View File

@ -19,7 +19,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
public: public:
typedef JsonArrayConstIterator iterator; using iterator = JsonArrayConstIterator;
// Returns an iterator to the first element of the array. // Returns an iterator to the first element of the array.
// https://arduinojson.org/v7/api/jsonarrayconst/begin/ // https://arduinojson.org/v7/api/jsonarrayconst/begin/

View File

@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <typename TWriter> template <typename TWriter>
class PrettyJsonSerializer : public JsonSerializer<TWriter> { class PrettyJsonSerializer : public JsonSerializer<TWriter> {
typedef JsonSerializer<TWriter> base; using base = JsonSerializer<TWriter>;
public: public:
PrettyJsonSerializer(TWriter writer, const ResourceManager* resources) PrettyJsonSerializer(TWriter writer, const ResourceManager* resources)

View File

@ -105,7 +105,7 @@ class TextFormatter {
template <typename T> template <typename T>
enable_if_t<is_signed<T>::value> writeInteger(T value) { enable_if_t<is_signed<T>::value> writeInteger(T value) {
typedef make_unsigned_t<T> unsigned_type; using unsigned_type = make_unsigned_t<T>;
unsigned_type unsigned_value; unsigned_type unsigned_value;
if (value < 0) { if (value < 0) {
writeRaw('-'); writeRaw('-');

View File

@ -20,7 +20,7 @@ struct FloatParts {
template <typename TFloat> template <typename TFloat>
inline int16_t normalize(TFloat& value) { inline int16_t normalize(TFloat& value) {
typedef FloatTraits<TFloat> traits; using traits = FloatTraits<TFloat>;
int16_t powersOf10 = 0; int16_t powersOf10 = 0;
int8_t index = sizeof(TFloat) == 8 ? 8 : 5; int8_t index = sizeof(TFloat) == 8 ? 8 : 5;

View File

@ -21,12 +21,12 @@ struct FloatTraits {};
template <typename T> template <typename T>
struct FloatTraits<T, 8 /*64bits*/> { struct FloatTraits<T, 8 /*64bits*/> {
typedef uint64_t mantissa_type; using mantissa_type = uint64_t;
static const short mantissa_bits = 52; static const short mantissa_bits = 52;
static const mantissa_type mantissa_max = static const mantissa_type mantissa_max =
(mantissa_type(1) << mantissa_bits) - 1; (mantissa_type(1) << mantissa_bits) - 1;
typedef int16_t exponent_type; using exponent_type = int16_t;
static const exponent_type exponent_max = 308; static const exponent_type exponent_max = 308;
static pgm_ptr<T> positiveBinaryPowersOfTen() { static pgm_ptr<T> positiveBinaryPowersOfTen() {
@ -105,12 +105,12 @@ struct FloatTraits<T, 8 /*64bits*/> {
template <typename T> template <typename T>
struct FloatTraits<T, 4 /*32bits*/> { struct FloatTraits<T, 4 /*32bits*/> {
typedef uint32_t mantissa_type; using mantissa_type = uint32_t;
static const short mantissa_bits = 23; static const short mantissa_bits = 23;
static const mantissa_type mantissa_max = static const mantissa_type mantissa_max =
(mantissa_type(1) << mantissa_bits) - 1; (mantissa_type(1) << mantissa_bits) - 1;
typedef int8_t exponent_type; using exponent_type = int8_t;
static const exponent_type exponent_max = 38; static const exponent_type exponent_max = 38;
static pgm_ptr<T> positiveBinaryPowersOfTen() { static pgm_ptr<T> positiveBinaryPowersOfTen() {

View File

@ -10,9 +10,9 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
#if ARDUINOJSON_USE_DOUBLE #if ARDUINOJSON_USE_DOUBLE
typedef double JsonFloat; using JsonFloat = double;
#else #else
typedef float JsonFloat; using JsonFloat = float;
#endif #endif
ARDUINOJSON_END_PUBLIC_NAMESPACE ARDUINOJSON_END_PUBLIC_NAMESPACE

View File

@ -12,11 +12,11 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
#if ARDUINOJSON_USE_LONG_LONG #if ARDUINOJSON_USE_LONG_LONG
typedef int64_t JsonInteger; using JsonInteger = int64_t;
typedef uint64_t JsonUInt; using JsonUInt = uint64_t;
#else #else
typedef long JsonInteger; using JsonInteger = long;
typedef unsigned long JsonUInt; using JsonUInt = unsigned long;
#endif #endif
ARDUINOJSON_END_PUBLIC_NAMESPACE ARDUINOJSON_END_PUBLIC_NAMESPACE

View File

@ -103,9 +103,9 @@ class Number {
}; };
inline Number parseNumber(const char* s) { inline Number parseNumber(const char* s) {
typedef FloatTraits<JsonFloat> traits; using traits = FloatTraits<JsonFloat>;
typedef largest_type<traits::mantissa_type, JsonUInt> mantissa_t; using mantissa_t = largest_type<traits::mantissa_type, JsonUInt>;
typedef traits::exponent_type exponent_t; using exponent_t = traits::exponent_type;
ARDUINOJSON_ASSERT(s != 0); ARDUINOJSON_ASSERT(s != 0);

View File

@ -17,7 +17,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
public: public:
typedef JsonObjectIterator iterator; using iterator = JsonObjectIterator;
// Creates an unbound reference. // Creates an unbound reference.
JsonObject() : data_(0), resources_(0) {} JsonObject() : data_(0), resources_(0) {}

View File

@ -16,7 +16,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
friend class detail::VariantAttorney; friend class detail::VariantAttorney;
public: public:
typedef JsonObjectConstIterator iterator; using iterator = JsonObjectConstIterator;
// Creates an unbound reference. // Creates an unbound reference.
JsonObjectConst() : data_(0), resources_(0) {} JsonObjectConst() : data_(0), resources_(0) {}

View File

@ -15,17 +15,17 @@ struct uint_;
template <> template <>
struct uint_<8> { struct uint_<8> {
typedef uint8_t type; using type = uint8_t;
}; };
template <> template <>
struct uint_<16> { struct uint_<16> {
typedef uint16_t type; using type = uint16_t;
}; };
template <> template <>
struct uint_<32> { struct uint_<32> {
typedef uint32_t type; using type = uint32_t;
}; };
template <int Bits> template <int Bits>

View File

@ -10,12 +10,12 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <bool Condition, class TrueType, class FalseType> template <bool Condition, class TrueType, class FalseType>
struct conditional { struct conditional {
typedef TrueType type; using type = TrueType;
}; };
template <class TrueType, class FalseType> template <class TrueType, class FalseType>
struct conditional<false, TrueType, FalseType> { struct conditional<false, TrueType, FalseType> {
typedef FalseType type; using type = FalseType;
}; };
template <bool Condition, class TrueType, class FalseType> template <bool Condition, class TrueType, class FalseType>

View File

@ -14,7 +14,7 @@ struct enable_if {};
template <typename T> template <typename T>
struct enable_if<true, T> { struct enable_if<true, T> {
typedef T type; using type = T;
}; };
template <bool Condition, typename T = void> template <bool Condition, typename T = void>

View File

@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// A meta-function that return the type T without the const modifier // A meta-function that return the type T without the const modifier
template <typename T> template <typename T>
struct remove_const { struct remove_const {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>
struct remove_const<const T> { struct remove_const<const T> {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>

View File

@ -10,19 +10,19 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <typename T> template <typename T>
struct remove_cv { struct remove_cv {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>
struct remove_cv<const T> { struct remove_cv<const T> {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>
struct remove_cv<volatile T> { struct remove_cv<volatile T> {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>
struct remove_cv<const volatile T> { struct remove_cv<const volatile T> {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>

View File

@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// A meta-function that return the type T without the reference modifier. // A meta-function that return the type T without the reference modifier.
template <typename T> template <typename T>
struct remove_reference { struct remove_reference {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>
struct remove_reference<T&> { struct remove_reference<T&> {
typedef T type; using type = T;
}; };
template <typename T> template <typename T>

View File

@ -10,7 +10,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <typename T> template <typename T>
struct type_identity { struct type_identity {
typedef T type; using type = T;
}; };
ARDUINOJSON_END_PRIVATE_NAMESPACE ARDUINOJSON_END_PRIVATE_NAMESPACE

View File

@ -74,7 +74,7 @@ class FlashString {
template <> template <>
struct StringAdapter<const __FlashStringHelper*, void> { struct StringAdapter<const __FlashStringHelper*, void> {
typedef FlashString AdaptedString; using AdaptedString = FlashString;
static AdaptedString adapt(const __FlashStringHelper* s) { static AdaptedString adapt(const __FlashStringHelper* s) {
return AdaptedString(s, s ? strlen_P(reinterpret_cast<const char*>(s)) : 0); return AdaptedString(s, s ? strlen_P(reinterpret_cast<const char*>(s)) : 0);
@ -83,7 +83,7 @@ struct StringAdapter<const __FlashStringHelper*, void> {
template <> template <>
struct SizedStringAdapter<const __FlashStringHelper*, void> { struct SizedStringAdapter<const __FlashStringHelper*, void> {
typedef FlashString AdaptedString; using AdaptedString = FlashString;
static AdaptedString adapt(const __FlashStringHelper* s, size_t n) { static AdaptedString adapt(const __FlashStringHelper* s, size_t n) {
return AdaptedString(s, n); return AdaptedString(s, n);

View File

@ -25,7 +25,7 @@ class JsonStringAdapter : public SizedRamString {
template <> template <>
struct StringAdapter<JsonString> { struct StringAdapter<JsonString> {
typedef JsonStringAdapter AdaptedString; using AdaptedString = JsonStringAdapter;
static AdaptedString adapt(const JsonString& s) { static AdaptedString adapt(const JsonString& s) {
return AdaptedString(s); return AdaptedString(s);

View File

@ -63,7 +63,7 @@ class ZeroTerminatedRamString {
template <typename TChar> template <typename TChar>
struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> { struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
typedef ZeroTerminatedRamString AdaptedString; using AdaptedString = ZeroTerminatedRamString;
static AdaptedString adapt(const TChar* p) { static AdaptedString adapt(const TChar* p) {
return AdaptedString(reinterpret_cast<const char*>(p)); return AdaptedString(reinterpret_cast<const char*>(p));
@ -72,7 +72,7 @@ struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
template <typename TChar, size_t N> template <typename TChar, size_t N>
struct StringAdapter<TChar[N], enable_if_t<IsChar<TChar>::value>> { struct StringAdapter<TChar[N], enable_if_t<IsChar<TChar>::value>> {
typedef ZeroTerminatedRamString AdaptedString; using AdaptedString = ZeroTerminatedRamString;
static AdaptedString adapt(const TChar* p) { static AdaptedString adapt(const TChar* p) {
return AdaptedString(reinterpret_cast<const char*>(p)); return AdaptedString(reinterpret_cast<const char*>(p));
@ -90,7 +90,7 @@ class StaticStringAdapter : public ZeroTerminatedRamString {
template <> template <>
struct StringAdapter<const char*, void> { struct StringAdapter<const char*, void> {
typedef StaticStringAdapter AdaptedString; using AdaptedString = StaticStringAdapter;
static AdaptedString adapt(const char* p) { static AdaptedString adapt(const char* p) {
return AdaptedString(p); return AdaptedString(p);
@ -132,7 +132,7 @@ class SizedRamString {
template <typename TChar> template <typename TChar>
struct SizedStringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> { struct SizedStringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
typedef SizedRamString AdaptedString; using AdaptedString = SizedRamString;
static AdaptedString adapt(const TChar* p, size_t n) { static AdaptedString adapt(const TChar* p, size_t n) {
return AdaptedString(reinterpret_cast<const char*>(p), n); return AdaptedString(reinterpret_cast<const char*>(p), n);

View File

@ -15,7 +15,7 @@ struct StringAdapter<
T, T,
enable_if_t<(string_traits<T>::has_cstr || string_traits<T>::has_data) && enable_if_t<(string_traits<T>::has_cstr || string_traits<T>::has_data) &&
(string_traits<T>::has_length || string_traits<T>::has_size)>> { (string_traits<T>::has_length || string_traits<T>::has_size)>> {
typedef SizedRamString AdaptedString; using AdaptedString = SizedRamString;
static AdaptedString adapt(const T& s) { static AdaptedString adapt(const T& s) {
return AdaptedString(get_data(s), get_size(s)); return AdaptedString(get_data(s), get_size(s));

View File

@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
class JsonVariantCopier { class JsonVariantCopier {
public: public:
typedef bool result_type; using result_type = bool;
JsonVariantCopier(JsonVariant dst) : dst_(dst) {} JsonVariantCopier(JsonVariant dst) : dst_(dst) {}

View File

@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <typename TResult> template <typename TResult>
struct JsonVariantVisitor { struct JsonVariantVisitor {
typedef TResult result_type; using result_type = TResult;
template <typename T> template <typename T>
TResult visit(const T&) { TResult visit(const T&) {

View File

@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
template <typename TResult> template <typename TResult>
struct VariantDataVisitor { struct VariantDataVisitor {
typedef TResult result_type; using result_type = TResult;
template <typename T> template <typename T>
TResult visit(const T&) { TResult visit(const T&) {

View File

@ -20,15 +20,15 @@ struct VariantTo {};
template <> template <>
struct VariantTo<JsonArray> { struct VariantTo<JsonArray> {
typedef JsonArray type; using type = JsonArray;
}; };
template <> template <>
struct VariantTo<JsonObject> { struct VariantTo<JsonObject> {
typedef JsonObject type; using type = JsonObject;
}; };
template <> template <>
struct VariantTo<JsonVariant> { struct VariantTo<JsonVariant> {
typedef JsonVariant type; using type = JsonVariant;
}; };
ARDUINOJSON_END_PRIVATE_NAMESPACE ARDUINOJSON_END_PRIVATE_NAMESPACE