Skip to content

Commit

Permalink
Replace all the typename =
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Dec 23, 2024
1 parent b3ca892 commit a4441e5
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/ArduinoJson/Array/JsonArray.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
// Appends a value to the array.
// https://arduinojson.org/v7/api/jsonarray/add/
template <typename T,
typename = detail::enable_if_t<!detail::is_const<T>::value>>
detail::enable_if_t<!detail::is_const<T>::value, int> = 0>
bool add(T* value) const {
return detail::ArrayData::addValue(data_, value, resources_);
}
Expand Down
23 changes: 11 additions & 12 deletions src/ArduinoJson/Array/Utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE

// Copies a value to a JsonVariant.
// This is a degenerated form of copyArray() to stop the recursion.
template <typename T,
typename = detail::enable_if_t<!detail::is_array<T>::value>>
template <typename T, detail::enable_if_t<!detail::is_array<T>::value, int> = 0>
inline bool copyArray(const T& src, JsonVariant dst) {
return dst.set(src);
}

// Copies values from an array to a JsonArray or a JsonVariant.
// https://arduinojson.org/v7/api/misc/copyarray/
template <typename T, size_t N, typename TDestination,
typename = detail::enable_if_t<
!detail::is_base_of<JsonDocument, TDestination>::value>>
detail::enable_if_t<
!detail::is_base_of<JsonDocument, TDestination>::value, int> = 0>
inline bool copyArray(T (&src)[N], const TDestination& dst) {
return copyArray(src, N, dst);
}

// Copies values from an array to a JsonArray or a JsonVariant.
// https://arduinojson.org/v7/api/misc/copyarray/
template <typename T, typename TDestination,
typename = detail::enable_if_t<
!detail::is_base_of<JsonDocument, TDestination>::value>>
detail::enable_if_t<
!detail::is_base_of<JsonDocument, TDestination>::value, int> = 0>
inline bool copyArray(const T* src, size_t len, const TDestination& dst) {
bool ok = true;
for (size_t i = 0; i < len; i++) {
Expand Down Expand Up @@ -62,8 +61,7 @@ inline bool copyArray(const T* src, size_t len, JsonDocument& dst) {

// Copies a value from a JsonVariant.
// This is a degenerated form of copyArray() to stop the recursion.
template <typename T,
typename = detail::enable_if_t<!detail::is_array<T>::value>>
template <typename T, detail::enable_if_t<!detail::is_array<T>::value, int> = 0>
inline size_t copyArray(JsonVariantConst src, T& dst) {
dst = src.as<T>();
return 1;
Expand Down Expand Up @@ -102,10 +100,11 @@ inline size_t copyArray(JsonVariantConst src, char (&dst)[N]) {

// Copies values from a JsonDocument to an array.
// https://arduinojson.org/v7/api/misc/copyarray/
template <typename TSource, typename T,
typename = detail::enable_if_t<
detail::is_array<T>::value &&
detail::is_base_of<JsonDocument, TSource>::value>>
template <
typename TSource, typename T,
detail::enable_if_t<detail::is_array<T>::value &&
detail::is_base_of<JsonDocument, TSource>::value,
int> = 0>
inline size_t copyArray(const TSource& src, T& dst) {
return copyArray(src.template as<JsonArrayConst>(), dst);
}
Expand Down
11 changes: 6 additions & 5 deletions src/ArduinoJson/Deserialization/deserialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ DeserializationError doDeserialize(TDestination&& dst, TReader reader,
return err;
}

template <template <typename> class TDeserializer, typename TDestination,
typename TStream, typename... Args,
typename = enable_if_t< // issue #1897
!is_integral<typename first_or_void<Args...>::type>::value>>
template <
template <typename> class TDeserializer, typename TDestination,
typename TStream, typename... Args,
enable_if_t< // issue #1897
!is_integral<typename first_or_void<Args...>::type>::value, int> = 0>
DeserializationError deserialize(TDestination&& dst, TStream&& input,
Args... args) {
return doDeserialize<TDeserializer>(
Expand All @@ -68,7 +69,7 @@ DeserializationError deserialize(TDestination&& dst, TStream&& input,

template <template <typename> class TDeserializer, typename TDestination,
typename TChar, typename Size, typename... Args,
typename = enable_if_t<is_integral<Size>::value>>
enable_if_t<is_integral<Size>::value, int> = 0>
DeserializationError deserialize(TDestination&& dst, TChar* input,
Size inputSize, Args... args) {
return doDeserialize<TDeserializer>(dst, makeReader(input, size_t(inputSize)),
Expand Down
43 changes: 24 additions & 19 deletions src/ArduinoJson/Document/JsonDocument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
}

// Construct from variant, array, or object
template <typename T, typename = detail::enable_if_t<
detail::IsVariant<T>::value ||
detail::is_same<T, JsonArray>::value ||
detail::is_same<T, JsonArrayConst>::value ||
detail::is_same<T, JsonObject>::value ||
detail::is_same<T, JsonObjectConst>::value>>
template <typename T,
detail::enable_if_t<detail::IsVariant<T>::value ||
detail::is_same<T, JsonArray>::value ||
detail::is_same<T, JsonArrayConst>::value ||
detail::is_same<T, JsonObject>::value ||
detail::is_same<T, JsonObjectConst>::value,
int> = 0>
JsonDocument(const T& src,
Allocator* alloc = detail::DefaultAllocator::instance())
: JsonDocument(alloc) {
Expand Down Expand Up @@ -136,16 +137,17 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {

// Replaces the root with the specified value.
// https://arduinojson.org/v7/api/jsondocument/set/
template <typename T, typename = detail::enable_if_t<
!detail::is_base_of<JsonDocument, T>::value>>
template <
typename T,
detail::enable_if_t<!detail::is_base_of<JsonDocument, T>::value, int> = 0>
bool set(const T& src) {
return to<JsonVariant>().set(src);
}

// Replaces the root with the specified value.
// https://arduinojson.org/v7/api/jsondocument/set/
template <typename TChar,
typename = detail::enable_if_t<!detail::is_const<TChar>::value>>
detail::enable_if_t<!detail::is_const<TChar>::value, int> = 0>
bool set(TChar* src) {
return to<JsonVariant>().set(src);
}
Expand Down Expand Up @@ -187,7 +189,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Gets or sets a root object's member.
// https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TString,
typename = detail::enable_if_t<detail::IsString<TString>::value>>
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
detail::MemberProxy<JsonDocument&, detail::AdaptedString<TString>> operator[](
const TString& key) {
return {*this, detail::adaptString(key)};
Expand All @@ -196,8 +198,9 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Gets or sets a root object's member.
// https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TChar,
typename = detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value>>
detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value,
int> = 0>
detail::MemberProxy<JsonDocument&, detail::AdaptedString<TChar*>> operator[](
TChar* key) {
return {*this, detail::adaptString(key)};
Expand All @@ -206,7 +209,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Gets a root object's member.
// https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TString,
typename = detail::enable_if_t<detail::IsString<TString>::value>>
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
JsonVariantConst operator[](const TString& key) const {
return JsonVariantConst(
data_.getMember(detail::adaptString(key), &resources_), &resources_);
Expand All @@ -215,8 +218,9 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Gets a root object's member.
// https://arduinojson.org/v7/api/jsondocument/subscript/
template <typename TChar,
typename = detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value>>
detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value,
int> = 0>
JsonVariantConst operator[](TChar* key) const {
return JsonVariantConst(
data_.getMember(detail::adaptString(key), &resources_), &resources_);
Expand Down Expand Up @@ -276,15 +280,15 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Appends a value to the root array.
// https://arduinojson.org/v7/api/jsondocument/add/
template <typename TChar,
typename = detail::enable_if_t<!detail::is_const<TChar>::value>>
detail::enable_if_t<!detail::is_const<TChar>::value, int> = 0>
bool add(TChar* value) {
return data_.addValue(value, &resources_);
}

// Removes an element of the root array.
// https://arduinojson.org/v7/api/jsondocument/remove/
template <typename T,
typename = detail::enable_if_t<detail::is_integral<T>::value>>
detail::enable_if_t<detail::is_integral<T>::value, int> = 0>
void remove(T index) {
detail::VariantData::removeElement(getData(), size_t(index),
getResourceManager());
Expand All @@ -293,8 +297,9 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
// Removes a member of the root object.
// https://arduinojson.org/v7/api/jsondocument/remove/
template <typename TChar,
typename = detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value>>
detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value,
int> = 0>
void remove(TChar* key) {
detail::VariantData::removeMember(getData(), detail::adaptString(key),
getResourceManager());
Expand Down
12 changes: 6 additions & 6 deletions src/ArduinoJson/Object/JsonObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
// Gets or sets the member with specified key.
// https://arduinojson.org/v7/api/jsonobject/subscript/
template <typename TString,
typename = detail::enable_if_t<detail::IsString<TString>::value>>
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
detail::MemberProxy<JsonObject, detail::AdaptedString<TString>> operator[](
const TString& key) const {
return {*this, detail::adaptString(key)};
Expand All @@ -111,8 +111,9 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
// Gets or sets the member with specified key.
// https://arduinojson.org/v7/api/jsonobject/subscript/
template <typename TChar,
typename = detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value>>
detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value,
int> = 0>
detail::MemberProxy<JsonObject, detail::AdaptedString<TChar*>> operator[](
TChar* key) const {
return {*this, detail::adaptString(key)};
Expand All @@ -121,7 +122,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
// Gets or sets the member with specified key.
// https://arduinojson.org/v7/api/jsonobject/subscript/
template <typename TVariant,
typename = detail::enable_if_t<detail::IsVariant<TVariant>::value>>
detail::enable_if_t<detail::IsVariant<TVariant>::value, int> = 0>
detail::MemberProxy<JsonObject, detail::AdaptedString<JsonString>> operator[](
const TVariant& key) const {
return {*this, detail::adaptString(key.template as<JsonString>())};
Expand Down Expand Up @@ -184,8 +185,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
// DEPRECATED: use obj[key].is<T>() instead
// https://arduinojson.org/v7/api/jsonobject/containskey/
template <typename TVariant,
typename = detail::enable_if_t<detail::IsVariant<TVariant>::value>,
int = 0>
detail::enable_if_t<detail::IsVariant<TVariant>::value, int> = 0>
ARDUINOJSON_DEPRECATED("use obj[key].is<T>() instead")
bool containsKey(const TVariant& key) const {
return containsKey(key.template as<const char*>());
Expand Down
10 changes: 5 additions & 5 deletions src/ArduinoJson/Object/JsonObjectConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
// Gets the member with specified key.
// https://arduinojson.org/v7/api/jsonobjectconst/subscript/
template <typename TString,
typename = detail::enable_if_t<detail::IsString<TString>::value>,
short = 1>
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
JsonVariantConst operator[](const TString& key) const {
return JsonVariantConst(detail::ObjectData::getMember(
data_, detail::adaptString(key), resources_),
Expand All @@ -110,8 +109,9 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
// Gets the member with specified key.
// https://arduinojson.org/v7/api/jsonobjectconst/subscript/
template <typename TChar,
typename = detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value>>
detail::enable_if_t<detail::IsString<TChar*>::value &&
!detail::is_const<TChar>::value,
int> = 0>
JsonVariantConst operator[](TChar* key) const {
return JsonVariantConst(detail::ObjectData::getMember(
data_, detail::adaptString(key), resources_),
Expand All @@ -121,7 +121,7 @@ class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
// Gets the member with specified key.
// https://arduinojson.org/v7/api/jsonobjectconst/subscript/
template <typename TVariant,
typename = detail::enable_if_t<detail::IsVariant<TVariant>::value>>
detail::enable_if_t<detail::IsVariant<TVariant>::value, int> = 0>
JsonVariantConst operator[](const TVariant& key) const {
if (key.template is<JsonString>())
return operator[](key.template as<JsonString>());
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Object/MemberProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MemberProxy
return *this;
}

template <typename T, typename = enable_if_t<!is_const<T>::value>>
template <typename T, enable_if_t<!is_const<T>::value, int> = 0>
MemberProxy& operator=(T* src) {
this->set(src);
return *this;
Expand Down
7 changes: 4 additions & 3 deletions src/ArduinoJson/Strings/JsonString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class JsonString {
JsonString(const char* data, bool isStatic = false)
: str_(data, data ? ::strlen(data) : 0, isStatic) {}

template <typename TSize, typename = detail::enable_if_t<
detail::is_integral<TSize>::value &&
!detail::is_same<TSize, bool>::value>>
template <typename TSize,
detail::enable_if_t<detail::is_integral<TSize>::value &&
!detail::is_same<TSize, bool>::value,
int> = 0>
JsonString(const char* data, TSize sz, bool isStatic = false)
: str_(data, size_t(sz), isStatic) {}

Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoJson/Strings/StringAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AdaptedString<TString> adaptString(TString&& s) {
return StringAdapterFor<TString>::adapt(detail::forward<TString>(s));
}

template <typename TChar, typename = enable_if_t<!is_const<TChar>::value>>
template <typename TChar, enable_if_t<!is_const<TChar>::value, int> = 0>
AdaptedString<TChar*> adaptString(TChar* p) {
return StringAdapter<TChar*>::adapt(p);
}
Expand Down
12 changes: 6 additions & 6 deletions src/ArduinoJson/Variant/JsonVariantConst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class JsonVariantConst : public detail::VariantTag,
// Casts the value to the specified type.
// https://arduinojson.org/v7/api/jsonvariantconst/as/
template <typename T,
typename = detail::enable_if_t<ConversionSupported<T>::value>>
detail::enable_if_t<ConversionSupported<T>::value, int> = 0>
T as() const {
return Converter<T>::fromJson(*this);
}

// Invalid conversion. Will not compile.
template <typename T, typename = detail::enable_if_t<
!ConversionSupported<T>::value, bool>>
template <typename T,
detail::enable_if_t<!ConversionSupported<T>::value, int> = 0>
detail::InvalidConversion<JsonVariantConst, T> as() const;

// Returns true if the value is of the specified type.
Expand All @@ -102,7 +102,7 @@ class JsonVariantConst : public detail::VariantTag,
// Gets array's element at specified index.
// https://arduinojson.org/v7/api/jsonvariantconst/subscript/
template <typename T,
typename = detail::enable_if_t<detail::is_integral<T>::value>>
detail::enable_if_t<detail::is_integral<T>::value, int> = 0>
JsonVariantConst operator[](T index) const {
return JsonVariantConst(
detail::VariantData::getElement(data_, size_t(index), resources_),
Expand All @@ -112,7 +112,7 @@ class JsonVariantConst : public detail::VariantTag,
// Gets object's member with specified key.
// https://arduinojson.org/v7/api/jsonvariantconst/subscript/
template <typename TString,
typename = detail::enable_if_t<detail::IsString<TString>::value>>
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
JsonVariantConst operator[](const TString& key) const {
return JsonVariantConst(detail::VariantData::getMember(
data_, detail::adaptString(key), resources_),
Expand Down Expand Up @@ -146,7 +146,7 @@ class JsonVariantConst : public detail::VariantTag,
// DEPRECATED: use obj[key].is<T>() instead
// https://arduinojson.org/v7/api/jsonvariantconst/containskey/
template <typename TString,
typename = detail::enable_if_t<detail::IsString<TString>::value>>
detail::enable_if_t<detail::IsString<TString>::value, int> = 0>
ARDUINOJSON_DEPRECATED("use var[key].is<T>() instead")
bool containsKey(const TString& key) const {
return detail::VariantData::getMember(getData(), detail::adaptString(key),
Expand Down
Loading

0 comments on commit a4441e5

Please sign in to comment.