json: compiling with gcc 7 -> error on bool operator <

when compiling i get

json.hpp:6395:66: error: wrong number of template arguments (1, should be 2) return *lhs.m_value.array < *rhs.m_value.array;

and

/usr/include/c++/7/array:94:12: note: provided for ‘template<class _Tp, long unsigned int _Nm> struct std::array’ struct array

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 22 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Changing the line in json.hpp to read

return (*lhs.m_value.array) < *rhs.m_value.array;

seems to fix the error using that simple test case. It’s quite possible this is a GCC bug; I can’t understand why .array< should be interpreted as template parameters to array with that . preceding it. Furthermore, clang compiles the snippet without issue in C++11 and in C++14 mode.

I tried to help @alberto2000 track this down in IRC earlier. In https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/utils/ofConstants.h#L435 – ‘using namespace std;’ is present and indirectly ahead of the include for json.hpp, which seems to trigger the issue.

@buffos – your code also has a ‘using namespace std;’ indirectly before json.hpp is included

@nlohmann – I did the same as @whenov and had the same error message about template arguments, which goes away if ‘using namespace std;’ is commented out. The test suite built and ran fine.