From 5c62f8baf3bff70c9a760d5e9764b44823cd3e5d Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Sun, 14 Oct 2018 21:53:34 +0300 Subject: [PATCH] V2: Fixed transform_attribute ambiguity Domain-agnostic class template partial specializations and type agnostic domain partial specializations are ambious. To resolve the ambiguity type agnostic domain partial specializations are dispatched via intermediate type. --- .../boost/spirit/home/karma/detail/attributes.hpp | 8 +++----- include/boost/spirit/home/qi/detail/attributes.hpp | 10 ++++++---- include/boost/spirit/home/support/attributes.hpp | 12 +++++++++++- test/qi/regression_adapt_adt.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/include/boost/spirit/home/karma/detail/attributes.hpp b/include/boost/spirit/home/karma/detail/attributes.hpp index c63faace37..a313e319ef 100644 --- a/include/boost/spirit/home/karma/detail/attributes.hpp +++ b/include/boost/spirit/home/karma/detail/attributes.hpp @@ -95,14 +95,12 @@ namespace boost { namespace spirit { namespace karma }}} /////////////////////////////////////////////////////////////////////////////// -namespace boost { namespace spirit { namespace traits +namespace boost { namespace spirit { namespace traits { namespace detail { template - struct transform_attribute + struct transform_attribute_base : karma::transform_attribute {}; -}}} +}}}} #endif - - diff --git a/include/boost/spirit/home/qi/detail/attributes.hpp b/include/boost/spirit/home/qi/detail/attributes.hpp index 6e8ce13f83..c5f5037d8c 100644 --- a/include/boost/spirit/home/qi/detail/attributes.hpp +++ b/include/boost/spirit/home/qi/detail/attributes.hpp @@ -143,10 +143,12 @@ namespace boost { namespace spirit { namespace qi /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace traits { - template - struct transform_attribute - : qi::transform_attribute - {}; + namespace detail { + template + struct transform_attribute_base + : qi::transform_attribute + {}; + } template struct transform_attribute diff --git a/include/boost/spirit/home/support/attributes.hpp b/include/boost/spirit/home/support/attributes.hpp index ceba157fcf..960a8af240 100644 --- a/include/boost/spirit/home/support/attributes.hpp +++ b/include/boost/spirit/home/support/attributes.hpp @@ -923,6 +923,14 @@ namespace boost { namespace spirit { namespace traits type; }; + namespace detail { + // Domain-agnostic class template partial specializations and + // type agnostic domain partial specializations are ambious. + // To resolve the ambiguity type agnostic domain partial + // specializations are dispatched via intermediate type. + template + struct transform_attribute_base; + } /////////////////////////////////////////////////////////////////////////// // transform_attribute // @@ -933,7 +941,9 @@ namespace boost { namespace spirit { namespace traits /////////////////////////////////////////////////////////////////////////// template - struct transform_attribute; + struct transform_attribute + : detail::transform_attribute_base + {}; /////////////////////////////////////////////////////////////////////////// template diff --git a/test/qi/regression_adapt_adt.cpp b/test/qi/regression_adapt_adt.cpp index 04ea6ddae0..4727853c3b 100644 --- a/test/qi/regression_adapt_adt.cpp +++ b/test/qi/regression_adapt_adt.cpp @@ -92,5 +92,12 @@ int main() data.str == "Hello" && !data.optstr); } + { // GH#396 + qi::rule uint_r = qi::uint_; + test1 data; + BOOST_TEST(test_attr("123@999", uint_r >> -('@' >> uint_r), data) && + data.var == 123 && data.opt && data.opt.get() == 999); + } + return boost::report_errors(); }