summaryrefslogtreecommitdiff
path: root/boost/spirit/home/karma/detail/extract_from.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/spirit/home/karma/detail/extract_from.hpp')
-rw-r--r--boost/spirit/home/karma/detail/extract_from.hpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/boost/spirit/home/karma/detail/extract_from.hpp b/boost/spirit/home/karma/detail/extract_from.hpp
index 558d056352..5499212824 100644
--- a/boost/spirit/home/karma/detail/extract_from.hpp
+++ b/boost/spirit/home/karma/detail/extract_from.hpp
@@ -44,40 +44,45 @@ namespace boost { namespace spirit { namespace traits
}
// This is the default case: the plain attribute values
- template <typename Attribute, typename Exposed, typename Enable/*= void*/>
- struct extract_from_attribute
+ template <typename Attribute, typename Exposed
+ , bool IsOneElemSeq = traits::one_element_sequence<Attribute>::value>
+ struct extract_from_attribute_base
{
- typedef typename traits::one_element_sequence<Attribute>::type
- is_one_element_sequence;
-
- typedef typename mpl::eval_if<
- is_one_element_sequence
- , detail::value_at_c<Attribute, 0>
- , mpl::identity<Attribute const&>
- >::type type;
+ typedef Attribute const& type;
template <typename Context>
- static type call(Attribute const& attr, Context&, mpl::false_)
+ static type call(Attribute const& attr, Context&)
{
return attr;
}
+ };
- // This handles the case where the attribute is a single element fusion
- // sequence. We silently extract the only element and treat it as the
- // attribute to generate output from.
- template <typename Context>
- static type call(Attribute const& attr, Context& ctx, mpl::true_)
- {
- return extract_from<Exposed>(fusion::at_c<0>(attr), ctx);
- }
+ // This handles the case where the attribute is a single element fusion
+ // sequence. We silently extract the only element and treat it as the
+ // attribute to generate output from.
+ template <typename Attribute, typename Exposed>
+ struct extract_from_attribute_base<Attribute, Exposed, true>
+ {
+ typedef typename remove_const<
+ typename remove_reference<
+ typename fusion::result_of::at_c<Attribute, 0>::type
+ >::type
+ >::type elem_type;
+
+ typedef typename result_of::extract_from<Exposed, elem_type>::type type;
template <typename Context>
static type call(Attribute const& attr, Context& ctx)
{
- return call(attr, ctx, is_one_element_sequence());
+ return extract_from<Exposed>(fusion::at_c<0>(attr), ctx);
}
};
+ template <typename Attribute, typename Exposed, typename Enable/*= void*/>
+ struct extract_from_attribute
+ : extract_from_attribute_base<Attribute, Exposed>
+ {};
+
// This handles optional attributes.
template <typename Attribute, typename Exposed>
struct extract_from_attribute<boost::optional<Attribute>, Exposed>