Skip to content

Commit

Permalink
tag dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
Kojoley committed Feb 26, 2018
1 parent 8b93d42 commit 8b76132
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions include/boost/spirit/home/x3/operator/detail/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,26 +392,24 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
, traits::container_attribute);

template <typename Parser, typename Context>
constexpr bool should_sequence_proxy = sequence_size<Parser, Context>::value > 1;
using should_sequence_proxy = mpl::bool_<(sequence_size<Parser, Context>::value > 1)>;

template <typename Parser, typename Iterator, typename Context
, typename RContext, typename Attribute>
typename enable_if_c<should_sequence_proxy<Parser, Context>, bool>::type
parse_into_container_or_proxy(
bool parse_into_container_or_proxy(
Parser const& parser
, Iterator& first, Iterator const& last, Context const& context
, RContext& rcontext, Attribute& attr)
, RContext& rcontext, Attribute& attr, mpl::true_)
{
return parser.parse(first, last, context, rcontext, attr);
}

template <typename Parser, typename Iterator, typename Context
, typename RContext, typename Attribute>
typename disable_if_c<should_sequence_proxy<Parser, Context>, bool>::type
parse_into_container_or_proxy(
bool parse_into_container_or_proxy(
Parser const& parser
, Iterator& first, Iterator const& last, Context const& context
, RContext& rcontext, Attribute& attr)
, RContext& rcontext, Attribute& attr, mpl::false_)
{
return parse_into_container(parser, first, last, context, rcontext, attr);
}
Expand All @@ -424,8 +422,8 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
, traits::container_attribute)
{
Iterator save = first;
if (parse_into_container_or_proxy(parser.left, first, last, context, rcontext, attr)
&& parse_into_container_or_proxy(parser.right, first, last, context, rcontext, attr))
if (parse_into_container_or_proxy(parser.left, first, last, context, rcontext, attr, should_sequence_proxy<Parser::left_type, Context>{})
&& parse_into_container_or_proxy(parser.right, first, last, context, rcontext, attr, should_sequence_proxy<Parser::right_type, Context>{}))
return true;
first = save;
return false;
Expand Down

0 comments on commit 8b76132

Please sign in to comment.