Fix build for Boost 1.77
A bug in Spirit prevented netconf-cli from with Boost 1.77. This patch
backports a fix directly to netconf-cli.
Issue: https://github.com/boostorg/spirit/issues/701
Change-Id: I8a044a57ebb4865b548230199ef0914ac2260978
diff --git a/src/grammars.hpp b/src/grammars.hpp
index dc116a9..354c029 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -15,6 +15,39 @@
#include "leaf_data.hpp"
#include "path_parser.hpp"
+#if BOOST_VERSION <= 107700
+namespace boost::spirit::x3::traits
+{
+ // Backport https://github.com/boostorg/spirit/pull/702
+ // with instructions from https://github.com/boostorg/spirit/issues/701#issuecomment-946743099
+ template <typename... Types, typename T>
+ struct variant_find_substitute<boost::variant<Types...>, T>
+ {
+ using variant_type = boost::variant<Types...>;
+
+ typedef typename variant_type::types types;
+ typedef typename mpl::end<types>::type end;
+
+ typedef typename mpl::find<types, T>::type iter_1;
+
+ typedef typename
+ mpl::eval_if<
+ is_same<iter_1, end>,
+ mpl::find_if<types, traits::is_substitute<T, mpl::_1> >,
+ mpl::identity<iter_1>
+ >::type
+ iter;
+
+ typedef typename
+ mpl::eval_if<
+ is_same<iter, end>,
+ mpl::identity<T>,
+ mpl::deref<iter>
+ >::type
+ type;
+ };
+}
+#endif
x3::rule<discard_class, discard_> const discard = "discard";
x3::rule<ls_class, ls_> const ls = "ls";