|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61499 - in trunk/boost/spirit/home/karma: detail directive operator
From: hartmut.kaiser_at_[hidden]
Date: 2010-04-22 21:13:09
Author: hkaiser
Date: 2010-04-22 21:13:08 EDT (Thu, 22 Apr 2010)
New Revision: 61499
URL: http://svn.boost.org/trac/boost/changeset/61499
Log:
Spirit: fixing gcc errors
Text files modified:
trunk/boost/spirit/home/karma/detail/pass_container.hpp | 17 +++++------------
trunk/boost/spirit/home/karma/directive/repeat.hpp | 6 ++----
trunk/boost/spirit/home/karma/operator/kleene.hpp | 6 ++----
trunk/boost/spirit/home/karma/operator/plus.hpp | 10 ++++------
trunk/boost/spirit/home/karma/operator/sequence.hpp | 40 ++++++++++++++++++++++++++--------------
5 files changed, 39 insertions(+), 40 deletions(-)
Modified: trunk/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/pass_container.hpp 2010-04-22 21:13:08 EDT (Thu, 22 Apr 2010)
@@ -127,13 +127,14 @@
// This function handles the case where the attribute (Attr) given
// to the sequence is an STL container. This is a wrapper around F.
// The function F does the actual generating.
- template <typename F, typename Attr>
+ template <typename F, typename Attr, typename Strict>
struct pass_container
{
typedef typename F::context_type context_type;
- typedef typename traits::container_iterator<Attr>::type iterator_type;
+ typedef typename traits::container_iterator<Attr const>::type
+ iterator_type;
- pass_container(F const& f, Attr& attr)
+ pass_container(F const& f, Attr const& attr)
: f(f), attr(attr), iter(traits::begin(attr)) {}
// this is for the case when the current element expects an attribute
@@ -236,6 +237,7 @@
typedef typename traits::attribute_of<
Component, context_type>::type lhs_attribute;
+ // false means everything went ok
return dispatch_main(component
, has_same_elements<rhs, lhs_attribute>());
}
@@ -248,15 +250,6 @@
// silence MSVC warning C4512: assignment operator could not be generated
pass_container& operator= (pass_container const&);
};
-
- // Utility function to make a pass_container
- template <typename F, typename Attr>
- pass_container<F, Attr>
- inline make_pass_container(F const& f, Attr& attr)
- {
- return pass_container<F, Attr>(f, attr);
- }
-
}}}}
#endif
Modified: trunk/boost/spirit/home/karma/directive/repeat.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/directive/repeat.hpp (original)
+++ trunk/boost/spirit/home/karma/directive/repeat.hpp 2010-04-22 21:13:08 EDT (Thu, 22 Apr 2010)
@@ -244,8 +244,7 @@
> base_repeat_generator_;
repeat_generator(Subject const& subject, LoopIter const& iter)
- : base_repeat_generator_(subject, iter)
- {}
+ : base_repeat_generator_(subject, iter) {}
};
template <typename Subject, typename LoopIter>
@@ -259,8 +258,7 @@
> base_repeat_generator_;
strict_repeat_generator(Subject const& subject, LoopIter const& iter)
- : base_repeat_generator_(subject, iter)
- {}
+ : base_repeat_generator_(subject, iter) {}
};
///////////////////////////////////////////////////////////////////////////
Modified: trunk/boost/spirit/home/karma/operator/kleene.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/kleene.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/kleene.hpp 2010-04-22 21:13:08 EDT (Thu, 22 Apr 2010)
@@ -119,8 +119,7 @@
typedef base_kleene<Subject, mpl::false_, kleene> base_kleene_;
kleene(Subject const& subject)
- : base_kleene_(subject)
- {}
+ : base_kleene_(subject) {}
};
template <typename Subject>
@@ -130,8 +129,7 @@
typedef base_kleene<Subject, mpl::true_, strict_kleene> base_kleene_;
strict_kleene(Subject const& subject)
- : base_kleene_(subject)
- {}
+ : base_kleene_(subject) {}
};
///////////////////////////////////////////////////////////////////////////
Modified: trunk/boost/spirit/home/karma/operator/plus.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/plus.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/plus.hpp 2010-04-22 21:13:08 EDT (Thu, 22 Apr 2010)
@@ -129,22 +129,20 @@
struct plus
: base_plus<Subject, mpl::false_, plus<Subject> >
{
- typedef base_plus<Subject, mpl::false_, plus> base_plus;
+ typedef base_plus<Subject, mpl::false_, plus> base_plus_;
plus(Subject const& subject)
- : base_plus(subject)
- {}
+ : base_plus_(subject) {}
};
template <typename Subject>
struct strict_plus
: base_plus<Subject, mpl::true_, strict_plus<Subject> >
{
- typedef base_plus<Subject, mpl::true_, strict_plus> base_plus;
+ typedef base_plus<Subject, mpl::true_, strict_plus> base_plus_;
strict_plus(Subject const& subject)
- : base_plus(subject)
- {}
+ : base_plus_(subject) {}
};
///////////////////////////////////////////////////////////////////////////
Modified: trunk/boost/spirit/home/karma/operator/sequence.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/operator/sequence.hpp (original)
+++ trunk/boost/spirit/home/karma/operator/sequence.hpp 2010-04-22 21:13:08 EDT (Thu, 22 Apr 2010)
@@ -97,12 +97,24 @@
{};
template <typename Attribute>
- inline int attr_size(Attribute const& attr)
+ inline typename enable_if<
+ fusion::traits::is_sequence<Attribute>, std::size_t
+ >::type
+ attr_size(Attribute const& attr)
{
return fusion::size(attr);
}
- inline int attr_size(unused_type)
+ template <typename Attribute>
+ inline typename enable_if<
+ traits::is_container<Attribute>, std::size_t
+ >::type
+ attr_size(Attribute const& attr)
+ {
+ return attr.size();
+ }
+
+ inline std::size_t attr_size(unused_type)
{
return 0;
}
@@ -163,17 +175,13 @@
>::type
>::type attr(attr_);
- // fail generating if sequences have not the same (logical) length
- if (Strict::value &&
- detail::attribute_size<attr_type_>::value !=
- detail::attr_size(attr_))
- {
- return false;
- }
-
// return false if *any* of the generators fail
- return !spirit::any_if(elements, attr, fail_function(sink, ctx, d)
- , predicate());
+ bool r = spirit::any_if(elements, attr
+ , fail_function(sink, ctx, d), predicate());
+
+ // fail generating if sequences have not the same (logical) length
+ return !r && (!Strict::value ||
+ detail::attribute_size<attr_type_>::value == detail::attr_size(attr_));
}
// Special case when Attribute is an stl container and the sequence's
@@ -189,8 +197,12 @@
typedef detail::fail_function<
OutputIterator, Context, Delimiter> fail_function;
- return !fusion::any(elements, detail::make_pass_container(
- fail_function(sink, ctx, d), attr_));
+ detail::pass_container<fail_function, Attribute, Strict> pass(
+ fail_function(sink, ctx, d), attr_);
+ bool r = fusion::any(elements, pass);
+
+ // fail generating if sequences have not the same (logical) length
+ return !r && (!Strict::value || pass.iter == traits::end(attr_));
}
// main generate function. Dispatches to generate_impl depending
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk