Fixed errors with Variable Length Arrays (issue #416)

This commit is contained in:
Benoit Blanchon
2017-01-15 15:11:26 +01:00
parent 11432253a1
commit 8499f0b960
15 changed files with 822 additions and 165 deletions

View File

@@ -78,20 +78,46 @@ class JsonVariantBase : public Internals::JsonPrintable<TImpl> {
// Returns the value associated with the specified key if the variant is
// an object.
// Return JsonVariant::invalid() if the variant is not an object.
//
// const JsonObjectSubscript operator[](TKey) const;
// TKey = const std::string&, const String&
template <typename TString>
FORCE_INLINE
typename TypeTraits::EnableIf<Internals::StringFuncs<TString>::has_equals,
const JsonObjectSubscript<TString> >::type
operator[](const TString &key) const {
FORCE_INLINE typename TypeTraits::EnableIf<
Internals::StringFuncs<TString>::has_equals,
const JsonObjectSubscript<const TString &> >::type
operator[](const TString &key) const {
return asObject()[key];
}
//
// const JsonObjectSubscript operator[](TKey) const;
// TKey = const char*, const char[N], const FlashStringHelper*
template <typename TString>
FORCE_INLINE
typename TypeTraits::EnableIf<Internals::StringFuncs<TString>::has_equals,
JsonObjectSubscript<TString> >::type
JsonObjectSubscript<const TString &> >::type
operator[](const TString &key) {
return asObject()[key];
}
//
// JsonObjectSubscript operator[](TKey);
// TKey = const std::string&, const String&
template <typename TString>
FORCE_INLINE typename TypeTraits::EnableIf<
Internals::StringFuncs<TString *>::has_equals,
JsonObjectSubscript<const TString *> >::type
operator[](const TString *key) {
return asObject()[key];
}
//
// JsonObjectSubscript operator[](TKey);
// TKey = const char*, const char[N], const FlashStringHelper*
template <typename TString>
FORCE_INLINE typename TypeTraits::EnableIf<
Internals::StringFuncs<TString *>::has_equals,
const JsonObjectSubscript<const TString *> >::type
operator[](const TString *key) const {
return asObject()[key];
}
private:
const TImpl *impl() const {