Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58919 - in trunk/boost/spirit/home/karma/numeric: . detail
From: hartmut.kaiser_at_[hidden]
Date: 2010-01-11 23:15:47


Author: hkaiser
Date: 2010-01-11 23:15:47 EST (Mon, 11 Jan 2010)
New Revision: 58919
URL: http://svn.boost.org/trac/boost/changeset/58919

Log:
Spirit: Allowing karma uint generators being invoked using signed integers
Text files modified:
   trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp | 18 ++++++++++++++++++
   trunk/boost/spirit/home/karma/numeric/uint.hpp | 6 +++---
   2 files changed, 21 insertions(+), 3 deletions(-)

Modified: trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp 2010-01-11 23:15:47 EST (Mon, 11 Jan 2010)
@@ -547,6 +547,24 @@
 #undef BOOST_KARMA_NUMERICS_INNER_LOOP_SUFFIX
 
     ///////////////////////////////////////////////////////////////////////////
+ template <
+ unsigned Radix, typename CharEncoding = unused_type
+ , typename Tag = unused_type>
+ struct uint_inserter : int_inserter<Radix, CharEncoding, Tag>
+ {
+ typedef int_inserter<Radix, CharEncoding, Tag> base_type;
+
+ // Common code for integer string representations
+ template <typename OutputIterator, typename T>
+ static bool
+ call(OutputIterator& sink, T const& n)
+ {
+ typename detail::absolute_value_helper<T>::result_type un = n;
+ return base_type::call(sink, un, un, 0);
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
     //
     // The sign_inserter template generates a sign for a given numeric value.
     //

Modified: trunk/boost/spirit/home/karma/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/uint.hpp 2010-01-11 23:15:47 EST (Mon, 11 Jan 2010)
@@ -249,7 +249,7 @@
             if (!traits::has_optional_value(attr))
                 return false; // fail if it's an uninitialized optional
 
- return int_inserter<Radix, CharEncoding, Tag>::
+ return uint_inserter<Radix, CharEncoding, Tag>::
                         call(sink, traits::extract_from(attr, context)) &&
                    delimit_out(sink, d); // always do post-delimiting
         }
@@ -315,7 +315,7 @@
             {
                 return false;
             }
- return int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
+ return uint_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
                    delimit_out(sink, d); // always do post-delimiting
         }
 
@@ -325,7 +325,7 @@
         bool generate(OutputIterator& sink, Context&, Delimiter const& d
           , unused_type) const
         {
- return int_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
+ return uint_inserter<Radix, CharEncoding, Tag>::call(sink, n_) &&
                    delimit_out(sink, d); // always do post-delimiting
         }
 


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