Skip to content

Commit

Permalink
Merge pull request #1643 from kevinlul/develop
Browse files Browse the repository at this point in the history
Fix json.hpp compilation issue with other typedefs with same name (Issue #1642)
  • Loading branch information
nlohmann authored Jul 1, 2019
2 parents 9a775bc + e616d09 commit 9289a23
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
12 changes: 6 additions & 6 deletions include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5750,25 +5750,25 @@ class basic_json
return (*lhs.m_value.array) < (*rhs.m_value.array);

case value_t::object:
return *lhs.m_value.object < *rhs.m_value.object;
return (*lhs.m_value.object) < (*rhs.m_value.object);

case value_t::null:
return false;

case value_t::string:
return *lhs.m_value.string < *rhs.m_value.string;
return (*lhs.m_value.string) < (*rhs.m_value.string);

case value_t::boolean:
return lhs.m_value.boolean < rhs.m_value.boolean;
return (lhs.m_value.boolean) < (rhs.m_value.boolean);

case value_t::number_integer:
return lhs.m_value.number_integer < rhs.m_value.number_integer;
return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);

case value_t::number_unsigned:
return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);

case value_t::number_float:
return lhs.m_value.number_float < rhs.m_value.number_float;
return (lhs.m_value.number_float) < (rhs.m_value.number_float);

default:
return false;
Expand Down
12 changes: 6 additions & 6 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18561,25 +18561,25 @@ class basic_json
return (*lhs.m_value.array) < (*rhs.m_value.array);

case value_t::object:
return *lhs.m_value.object < *rhs.m_value.object;
return (*lhs.m_value.object) < (*rhs.m_value.object);

case value_t::null:
return false;

case value_t::string:
return *lhs.m_value.string < *rhs.m_value.string;
return (*lhs.m_value.string) < (*rhs.m_value.string);

case value_t::boolean:
return lhs.m_value.boolean < rhs.m_value.boolean;
return (lhs.m_value.boolean) < (rhs.m_value.boolean);

case value_t::number_integer:
return lhs.m_value.number_integer < rhs.m_value.number_integer;
return (lhs.m_value.number_integer) < (rhs.m_value.number_integer);

case value_t::number_unsigned:
return lhs.m_value.number_unsigned < rhs.m_value.number_unsigned;
return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned);

case value_t::number_float:
return lhs.m_value.number_float < rhs.m_value.number_float;
return (lhs.m_value.number_float) < (rhs.m_value.number_float);

default:
return false;
Expand Down
10 changes: 10 additions & 0 deletions test/src/unit-regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1799,3 +1799,13 @@ TEST_CASE("regression tests, exceptions dependent")
}
}
#endif

/////////////////////////////////////////////////////////////////////
// for #1642
/////////////////////////////////////////////////////////////////////
template <typename T> class array {};
template <typename T> class object {};
template <typename T> class string {};
template <typename T> class number_integer {};
template <typename T> class number_unsigned {};
template <typename T> class number_float {};

0 comments on commit 9289a23

Please sign in to comment.