You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Boost.Test, where until recently I could compare two Json::Value objects like this:
Json::Value actual = ...;
Json::Value expected = ...;
BOOST_TEST(actual==expected);
This stopped working when I upgraded to boost 1.65.0, where I now get the following compiler error:
In file included from /usr/local/include/boost/test/tools/collection_comparison_op.hpp:18:0,
from /usr/local/include/boost/test/test_tools.hpp:55,
from /usr/local/include/boost/test/unit_test.hpp:18,
from /home/wolfram/src/myfile.cpp:9:
/usr/local/include/boost/test/utils/is_forward_iterable.hpp: In instantiation of ‘struct boost::unit_test::bt_iterator_traits<Json::Value, true>’:
/usr/local/include/boost/test/tools/collection_comparison_op.hpp:437:5720: required from ‘struct boost::test_tools::assertion::op::EQ<Json::Value, Json::Value, void>’
/usr/local/include/boost/test/tools/assertion.hpp:326:7: required from ‘class boost::test_tools::assertion::binary_expr<boost::test_tools::assertion::value_expr<Json::Value&>, Json::Value&, boost::test_tools::assertion::op::EQ<Json::Value, Json::Value, void> >’
/home/wolfram/src/myfile.cpp:122:17: required from here
/usr/local/include/boost/test/utils/is_forward_iterable.hpp:206:36: error: no type named ‘value_type’ in ‘class Json::Value’
typedef typename T::value_type value_type;
^
One solution to make it compile is by adding the following line to Json::Value:
typedef std::string value_type;
at the end of the initial list of typedefs, like so (using jsoncpp 1.8.3):
$ git diff
diff --git a/include/json/json.h b/include/json/json.h
index ac2e884..de5a9df 100644
--- a/include/json/json.h
+++ b/include/json/json.h
@@ -634,6 +634,7 @@ public:
typedef Json::LargestInt LargestInt;
typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex;
+ typedef std::string value_type;
static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
Now it builds and my tests pass. The question is, is this a good solution? I don't know enough about either how jsoncpp works or how BOOST_TEST works to tell.
Any help is appreciated. If I get a thumbs up from an expert on these matters I'll supply a merge request for this change.
Hello,
I use Boost.Test, where until recently I could compare two Json::Value objects like this:
Json::Value actual = ...; Json::Value expected = ...; BOOST_TEST(actual==expected);
This stopped working when I upgraded to boost 1.65.0, where I now get the following compiler error:
One solution to make it compile is by adding the following line to Json::Value:
typedef std::string value_type;
at the end of the initial list of typedefs, like so (using jsoncpp 1.8.3):
Now it builds and my tests pass. The question is, is this a good solution? I don't know enough about either how jsoncpp works or how BOOST_TEST works to tell.
Any help is appreciated. If I get a thumbs up from an expert on these matters I'll supply a merge request for this change.
Thanks!
PS: Another way to make my test program work is
BOOST_TEST(actual.toStyledString()==expected.toStyledString());
but I find this a lot less elegant than directly comparing the Json::Value objects.
The text was updated successfully, but these errors were encountered: