Skip to content

Commit

Permalink
Replace typedef with using
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Oct 23, 2024
1 parent 61ec2c4 commit c6c0649
Show file tree
Hide file tree
Showing 30 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion extras/tests/JsonDocument/ElementProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "Literals.hpp"

typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy;
using ElementProxy = ArduinoJson::detail::ElementProxy<JsonDocument&>;

TEST_CASE("ElementProxy::add()") {
JsonDocument doc;
Expand Down
4 changes: 2 additions & 2 deletions extras/tests/JsonDocument/MemberProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
using ArduinoJson::detail::sizeofArray;
using ArduinoJson::detail::sizeofObject;

typedef ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>
MemberProxy;
using MemberProxy =
ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>;

TEST_CASE("MemberProxy::add()") {
JsonDocument doc;
Expand Down
2 changes: 1 addition & 1 deletion extras/tests/JsonVariant/stl_containers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ TEST_CASE("vector<int>") {
}

TEST_CASE("array<int, 2>") {
typedef std::array<int, 2> array_type;
using array_type = std::array<int, 2>;

SECTION("toJson") {
array_type v;
Expand Down
2 changes: 1 addition & 1 deletion extras/tests/Misc/custom_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

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>;
2 changes: 1 addition & 1 deletion src/ArduinoJson/Array/JsonArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
friend class detail::VariantAttorney;

public:
typedef JsonArrayIterator iterator;
using iterator = JsonArrayIterator;

// Constructs an unbound reference.
JsonArray() : data_(0), resources_(0) {}
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Array/JsonArrayConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
friend class detail::VariantAttorney;

public:
typedef JsonArrayConstIterator iterator;
using iterator = JsonArrayConstIterator;

// Returns an iterator to the first element of the array.
// https://arduinojson.org/v7/api/jsonarrayconst/begin/
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Json/PrettyJsonSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

template <typename TWriter>
class PrettyJsonSerializer : public JsonSerializer<TWriter> {
typedef JsonSerializer<TWriter> base;
using base = JsonSerializer<TWriter>;

public:
PrettyJsonSerializer(TWriter writer, const ResourceManager* resources)
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Json/TextFormatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TextFormatter {

template <typename T>
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;
if (value < 0) {
writeRaw('-');
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Numbers/FloatParts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct FloatParts {

template <typename TFloat>
inline int16_t normalize(TFloat& value) {
typedef FloatTraits<TFloat> traits;
using traits = FloatTraits<TFloat>;
int16_t powersOf10 = 0;

int8_t index = sizeof(TFloat) == 8 ? 8 : 5;
Expand Down
8 changes: 4 additions & 4 deletions src/ArduinoJson/Numbers/FloatTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ struct FloatTraits {};

template <typename T>
struct FloatTraits<T, 8 /*64bits*/> {
typedef uint64_t mantissa_type;
using mantissa_type = uint64_t;
static const short mantissa_bits = 52;
static const mantissa_type mantissa_max =
(mantissa_type(1) << mantissa_bits) - 1;

typedef int16_t exponent_type;
using exponent_type = int16_t;
static const exponent_type exponent_max = 308;

static pgm_ptr<T> positiveBinaryPowersOfTen() {
Expand Down Expand Up @@ -105,12 +105,12 @@ struct FloatTraits<T, 8 /*64bits*/> {

template <typename T>
struct FloatTraits<T, 4 /*32bits*/> {
typedef uint32_t mantissa_type;
using mantissa_type = uint32_t;
static const short mantissa_bits = 23;
static const mantissa_type mantissa_max =
(mantissa_type(1) << mantissa_bits) - 1;

typedef int8_t exponent_type;
using exponent_type = int8_t;
static const exponent_type exponent_max = 38;

static pgm_ptr<T> positiveBinaryPowersOfTen() {
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/Numbers/JsonFloat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

#if ARDUINOJSON_USE_DOUBLE
typedef double JsonFloat;
using JsonFloat = double;
#else
typedef float JsonFloat;
using JsonFloat = float;
#endif

ARDUINOJSON_END_PUBLIC_NAMESPACE
8 changes: 4 additions & 4 deletions src/ArduinoJson/Numbers/JsonInteger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

#if ARDUINOJSON_USE_LONG_LONG
typedef int64_t JsonInteger;
typedef uint64_t JsonUInt;
using JsonInteger = int64_t;
using JsonUInt = uint64_t;
#else
typedef long JsonInteger;
typedef unsigned long JsonUInt;
using JsonInteger = long;
using JsonUInt = unsigned long;
#endif

ARDUINOJSON_END_PUBLIC_NAMESPACE
Expand Down
6 changes: 3 additions & 3 deletions src/ArduinoJson/Numbers/parseNumber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class Number {
};

inline Number parseNumber(const char* s) {
typedef FloatTraits<JsonFloat> traits;
typedef largest_type<traits::mantissa_type, JsonUInt> mantissa_t;
typedef traits::exponent_type exponent_t;
using traits = FloatTraits<JsonFloat>;
using mantissa_t = largest_type<traits::mantissa_type, JsonUInt>;
using exponent_t = traits::exponent_type;

ARDUINOJSON_ASSERT(s != 0);

Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Object/JsonObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
friend class detail::VariantAttorney;

public:
typedef JsonObjectIterator iterator;
using iterator = JsonObjectIterator;

// Creates an unbound reference.
JsonObject() : data_(0), resources_(0) {}
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Object/JsonObjectConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
friend class detail::VariantAttorney;

public:
typedef JsonObjectConstIterator iterator;
using iterator = JsonObjectConstIterator;

// Creates an unbound reference.
JsonObjectConst() : data_(0), resources_(0) {}
Expand Down
6 changes: 3 additions & 3 deletions src/ArduinoJson/Polyfills/integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ struct uint_;

template <>
struct uint_<8> {
typedef uint8_t type;
using type = uint8_t;
};

template <>
struct uint_<16> {
typedef uint16_t type;
using type = uint16_t;
};

template <>
struct uint_<32> {
typedef uint32_t type;
using type = uint32_t;
};

template <int Bits>
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/Polyfills/type_traits/conditional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

template <bool Condition, class TrueType, class FalseType>
struct conditional {
typedef TrueType type;
using type = TrueType;
};

template <class TrueType, class FalseType>
struct conditional<false, TrueType, FalseType> {
typedef FalseType type;
using type = FalseType;
};

template <bool Condition, class TrueType, class FalseType>
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Polyfills/type_traits/enable_if.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct enable_if {};

template <typename T>
struct enable_if<true, T> {
typedef T type;
using type = T;
};

template <bool Condition, typename T = void>
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/Polyfills/type_traits/remove_const.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// A meta-function that return the type T without the const modifier
template <typename T>
struct remove_const {
typedef T type;
using type = T;
};
template <typename T>
struct remove_const<const T> {
typedef T type;
using type = T;
};

template <typename T>
Expand Down
8 changes: 4 additions & 4 deletions src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

template <typename T>
struct remove_cv {
typedef T type;
using type = T;
};
template <typename T>
struct remove_cv<const T> {
typedef T type;
using type = T;
};
template <typename T>
struct remove_cv<volatile T> {
typedef T type;
using type = T;
};
template <typename T>
struct remove_cv<const volatile T> {
typedef T type;
using type = T;
};

template <typename T>
Expand Down
4 changes: 2 additions & 2 deletions src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
// A meta-function that return the type T without the reference modifier.
template <typename T>
struct remove_reference {
typedef T type;
using type = T;
};
template <typename T>
struct remove_reference<T&> {
typedef T type;
using type = T;
};

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Polyfills/type_traits/type_identity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

template <typename T>
struct type_identity {
typedef T type;
using type = T;
};

ARDUINOJSON_END_PRIVATE_NAMESPACE
4 changes: 2 additions & 2 deletions src/ArduinoJson/Strings/Adapters/FlashString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class FlashString {

template <>
struct StringAdapter<const __FlashStringHelper*, void> {
typedef FlashString AdaptedString;
using AdaptedString = FlashString;

static AdaptedString adapt(const __FlashStringHelper* s) {
return AdaptedString(s, s ? strlen_P(reinterpret_cast<const char*>(s)) : 0);
Expand All @@ -83,7 +83,7 @@ struct StringAdapter<const __FlashStringHelper*, void> {

template <>
struct SizedStringAdapter<const __FlashStringHelper*, void> {
typedef FlashString AdaptedString;
using AdaptedString = FlashString;

static AdaptedString adapt(const __FlashStringHelper* s, size_t n) {
return AdaptedString(s, n);
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Strings/Adapters/JsonString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JsonStringAdapter : public SizedRamString {

template <>
struct StringAdapter<JsonString> {
typedef JsonStringAdapter AdaptedString;
using AdaptedString = JsonStringAdapter;

static AdaptedString adapt(const JsonString& s) {
return AdaptedString(s);
Expand Down
8 changes: 4 additions & 4 deletions src/ArduinoJson/Strings/Adapters/RamString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ZeroTerminatedRamString {

template <typename TChar>
struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
typedef ZeroTerminatedRamString AdaptedString;
using AdaptedString = ZeroTerminatedRamString;

static AdaptedString adapt(const TChar* p) {
return AdaptedString(reinterpret_cast<const char*>(p));
Expand All @@ -72,7 +72,7 @@ struct StringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {

template <typename TChar, size_t N>
struct StringAdapter<TChar[N], enable_if_t<IsChar<TChar>::value>> {
typedef ZeroTerminatedRamString AdaptedString;
using AdaptedString = ZeroTerminatedRamString;

static AdaptedString adapt(const TChar* p) {
return AdaptedString(reinterpret_cast<const char*>(p));
Expand All @@ -90,7 +90,7 @@ class StaticStringAdapter : public ZeroTerminatedRamString {

template <>
struct StringAdapter<const char*, void> {
typedef StaticStringAdapter AdaptedString;
using AdaptedString = StaticStringAdapter;

static AdaptedString adapt(const char* p) {
return AdaptedString(p);
Expand Down Expand Up @@ -132,7 +132,7 @@ class SizedRamString {

template <typename TChar>
struct SizedStringAdapter<TChar*, enable_if_t<IsChar<TChar>::value>> {
typedef SizedRamString AdaptedString;
using AdaptedString = SizedRamString;

static AdaptedString adapt(const TChar* p, size_t n) {
return AdaptedString(reinterpret_cast<const char*>(p), n);
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Strings/Adapters/StringObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct StringAdapter<
T,
enable_if_t<(string_traits<T>::has_cstr || string_traits<T>::has_data) &&
(string_traits<T>::has_length || string_traits<T>::has_size)>> {
typedef SizedRamString AdaptedString;
using AdaptedString = SizedRamString;

static AdaptedString adapt(const T& s) {
return AdaptedString(get_data(s), get_size(s));
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Variant/JsonVariantCopier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

class JsonVariantCopier {
public:
typedef bool result_type;
using result_type = bool;

JsonVariantCopier(JsonVariant dst) : dst_(dst) {}

Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Variant/JsonVariantVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

template <typename TResult>
struct JsonVariantVisitor {
typedef TResult result_type;
using result_type = TResult;

template <typename T>
TResult visit(const T&) {
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Variant/VariantDataVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE

template <typename TResult>
struct VariantDataVisitor {
typedef TResult result_type;
using result_type = TResult;

template <typename T>
TResult visit(const T&) {
Expand Down
6 changes: 3 additions & 3 deletions src/ArduinoJson/Variant/VariantTo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ struct VariantTo {};

template <>
struct VariantTo<JsonArray> {
typedef JsonArray type;
using type = JsonArray;
};
template <>
struct VariantTo<JsonObject> {
typedef JsonObject type;
using type = JsonObject;
};
template <>
struct VariantTo<JsonVariant> {
typedef JsonVariant type;
using type = JsonVariant;
};

ARDUINOJSON_END_PRIVATE_NAMESPACE

0 comments on commit c6c0649

Please sign in to comment.