Fixed error forming reference to reference (issue #495)

This commit is contained in:
Benoit Blanchon
2017-05-04 21:58:28 +02:00
parent 9efc0ec40d
commit cc66618e70
3 changed files with 17 additions and 12 deletions

View File

@ -5,6 +5,7 @@ HEAD
---- ----
* Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495) * Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495)
* Fixed error `forming reference to reference` (issue #495)
v5.9.0 v5.9.0
------ ------

View File

@ -15,22 +15,21 @@
namespace ArduinoJson { namespace ArduinoJson {
namespace Internals { namespace Internals {
template <typename TSource, typename Enable = void> template <typename TSourceRef, typename Enable = void>
struct ValueSetter { struct ValueSetter {
template <typename TDestination> template <typename TDestination>
static bool set(JsonBuffer*, TDestination& destination, static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) {
const TSource& source) {
destination = source; destination = source;
return true; return true;
} }
}; };
template <typename TSource> template <typename TSourceRef>
struct ValueSetter<TSource, typename TypeTraits::EnableIf<StringTraits< struct ValueSetter<TSourceRef, typename TypeTraits::EnableIf<StringTraits<
TSource>::should_duplicate>::type> { TSourceRef>::should_duplicate>::type> {
template <typename TDestination> template <typename TDestination>
static bool set(JsonBuffer* buffer, TDestination& destination, static bool set(JsonBuffer* buffer, TDestination& destination,
const TSource& source) { TSourceRef source) {
const char* copy = buffer->strdup(source); const char* copy = buffer->strdup(source);
if (!copy) return false; if (!copy) return false;
destination = copy; destination = copy;
@ -38,12 +37,11 @@ struct ValueSetter<TSource, typename TypeTraits::EnableIf<StringTraits<
} }
}; };
template <typename TSource> template <typename TSourceRef>
struct ValueSetter<TSource, typename TypeTraits::EnableIf<!StringTraits< struct ValueSetter<TSourceRef, typename TypeTraits::EnableIf<!StringTraits<
TSource>::should_duplicate>::type> { TSourceRef>::should_duplicate>::type> {
template <typename TDestination> template <typename TDestination>
static bool set(JsonBuffer*, TDestination& destination, static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) {
const TSource& source) {
// unsigned char* -> char* // unsigned char* -> char*
destination = reinterpret_cast<const char*>(source); destination = reinterpret_cast<const char*>(source);
return true; return true;

View File

@ -29,6 +29,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
-Wstrict-overflow=5 -Wstrict-overflow=5
-Wundef -Wundef
) )
if(NOT MINGW)
add_compile_options(
-std=c++98
)
endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")