Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49436 - in trunk/boost/xpressive: . detail/core/matcher detail/dynamic
From: eric_at_[hidden]
Date: 2008-10-22 15:17:45


Author: eric_niebler
Date: 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
New Revision: 49436
URL: http://svn.boost.org/trac/boost/changeset/49436

Log:
add support for Boost.Exception
Text files modified:
   trunk/boost/xpressive/basic_regex.hpp | 10 +++++++++-
   trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp | 4 ++--
   trunk/boost/xpressive/detail/core/matcher/lookbehind_matcher.hpp | 2 +-
   trunk/boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp | 2 +-
   trunk/boost/xpressive/detail/core/matcher/regex_matcher.hpp | 2 +-
   trunk/boost/xpressive/detail/dynamic/dynamic.hpp | 2 +-
   trunk/boost/xpressive/detail/dynamic/matchable.hpp | 2 +-
   trunk/boost/xpressive/detail/dynamic/parse_charset.hpp | 32 ++++++++++++++++----------------
   trunk/boost/xpressive/detail/dynamic/parser_traits.hpp | 36 ++++++++++++++++++------------------
   trunk/boost/xpressive/match_results.hpp | 32 ++++++++++++++++----------------
   trunk/boost/xpressive/regex_actions.hpp | 8 ++++----
   trunk/boost/xpressive/regex_compiler.hpp | 32 ++++++++++++++++----------------
   trunk/boost/xpressive/regex_error.hpp | 29 +++++++++++++++++------------
   13 files changed, 103 insertions(+), 90 deletions(-)

Modified: trunk/boost/xpressive/basic_regex.hpp
==============================================================================
--- trunk/boost/xpressive/basic_regex.hpp (original)
+++ trunk/boost/xpressive/basic_regex.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -35,6 +35,14 @@
 namespace boost { namespace xpressive
 {
 
+namespace detail
+{
+ inline void throw_on_stack_error(bool stack_error)
+ {
+ BOOST_XPR_ENSURE_(!stack_error, regex_constants::error_stack, "Regex stack space exhausted");
+ }
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 // basic_regex
 //
@@ -214,7 +222,7 @@
             stack_error = true;
             _resetstkoflw();
         }
- detail::ensure(!stack_error, regex_constants::error_stack, "Regex stack space exhausted");
+ detail::throw_on_stack_error(stack_error);
         return success;
         #else
         return proto::arg(*this)->xpr_->match(state);

Modified: trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -188,7 +188,7 @@
                 action_args_type::const_iterator where_ = ctx.args().find(&typeid(proto::arg(expr)));
                 if(where_ == ctx.args().end())
                 {
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
                         regex_error(
                             regex_constants::error_badarg
                           , "An argument to an action was unspecified"
@@ -331,7 +331,7 @@
 
         operator reference() const
         {
- detail::ensure(0 != this->t_, regex_constants::error_badattr, "Use of uninitialized regex attribute");
+ BOOST_XPR_ENSURE_(0 != this->t_, regex_constants::error_badattr, "Use of uninitialized regex attribute");
             return *this->t_;
         }
 

Modified: trunk/boost/xpressive/detail/core/matcher/lookbehind_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/lookbehind_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/lookbehind_matcher.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -39,7 +39,7 @@
           , pure_(pure)
           , width_(width)
         {
- detail::ensure(!is_unknown(this->width_), regex_constants::error_badlookbehind,
+ BOOST_XPR_ENSURE_(!is_unknown(this->width_), regex_constants::error_badlookbehind,
                 "Variable-width look-behind assertions are not supported");
         }
 

Modified: trunk/boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/regex_byref_matcher.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -52,7 +52,7 @@
         bool match(match_state<BidiIter> &state, Next const &next) const
         {
             BOOST_ASSERT(this->pimpl_ == this->wimpl_.lock().get());
- ensure(this->pimpl_->xpr_, regex_constants::error_badref, "bad regex reference");
+ BOOST_XPR_ENSURE_(this->pimpl_->xpr_, regex_constants::error_badref, "bad regex reference");
 
             return push_context_match(*this->pimpl_, state, this->wrap_(next, is_static_xpression<Next>()));
         }

Modified: trunk/boost/xpressive/detail/core/matcher/regex_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/regex_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/regex_matcher.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -42,7 +42,7 @@
             this->impl_.mark_count_ = impl->mark_count_;
             this->impl_.hidden_mark_count_ = impl->hidden_mark_count_;
 
- ensure(this->impl_.xpr_, regex_constants::error_badref, "bad regex reference");
+ BOOST_XPR_ENSURE_(this->impl_.xpr_, regex_constants::error_badref, "bad regex reference");
         }
 
         template<typename Next>

Modified: trunk/boost/xpressive/detail/dynamic/dynamic.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/dynamic.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/dynamic.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -113,7 +113,7 @@
     {
         if(quant_none == seq.quant())
         {
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
                 regex_error(regex_constants::error_badrepeat, "expression cannot be quantified")
             );
         }

Modified: trunk/boost/xpressive/detail/dynamic/matchable.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/matchable.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/matchable.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -69,7 +69,7 @@
 
     virtual void repeat(quant_spec const &, sequence<BidiIter> &) const
     {
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
             regex_error(regex_constants::error_badrepeat, "expression cannot be quantified")
         );
     }

Modified: trunk/boost/xpressive/detail/dynamic/parse_charset.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/parse_charset.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/parse_charset.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -54,7 +54,7 @@
     {
         if(numeric::cInRange != result)
         {
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
                 regex_error(
                     regex_constants::error_escape
                   , "character escape too large to fit in target character type"
@@ -81,7 +81,7 @@
     BOOST_MPL_ASSERT_RELATION(sizeof(uchar_t), ==, sizeof(char_type));
     typedef numeric::conversion_traits<uchar_t, int> converstion_traits;
 
- ensure(begin != end, error_escape, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_(begin != end, error_escape, "unexpected end of pattern found");
     numeric::converter<int, uchar_t, converstion_traits, char_overflow_handler> converter;
     escape_value<char_type,char_class_type> esc = { 0, 0, 0, escape_char };
     bool const icase = (0 != (regex_constants::icase_ & traits.flags()));
@@ -115,8 +115,8 @@
         break;
     // control character
     case BOOST_XPR_CHAR_(char_type, 'c'):
- ensure(++begin != end, error_escape, "unexpected end of pattern found");
- ensure
+ BOOST_XPR_ENSURE_(++begin != end, error_escape, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_
         (
             rxtraits.in_range(BOOST_XPR_CHAR_(char_type, 'a'), BOOST_XPR_CHAR_(char_type, 'z'), *begin)
          || rxtraits.in_range(BOOST_XPR_CHAR_(char_type, 'A'), BOOST_XPR_CHAR_(char_type, 'Z'), *begin)
@@ -154,18 +154,18 @@
         break;
     // hex escape sequence
     case BOOST_XPR_CHAR_(char_type, 'x'):
- ensure(++begin != end, error_escape, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_(++begin != end, error_escape, "unexpected end of pattern found");
         tmp = begin;
         esc.ch_ = converter(toi(begin, end, rxtraits, 16, 0xff));
- ensure(2 == std::distance(tmp, begin), error_escape, "invalid hex escape : "
+ BOOST_XPR_ENSURE_(2 == std::distance(tmp, begin), error_escape, "invalid hex escape : "
             "must be \\x HexDigit HexDigit");
         break;
     // Unicode escape sequence
     case BOOST_XPR_CHAR_(char_type, 'u'):
- ensure(++begin != end, error_escape, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_(++begin != end, error_escape, "unexpected end of pattern found");
         tmp = begin;
         esc.ch_ = converter(toi(begin, end, rxtraits, 16, 0xffff));
- ensure(4 == std::distance(tmp, begin), error_escape, "invalid Unicode escape : "
+ BOOST_XPR_ENSURE_(4 == std::distance(tmp, begin), error_escape, "invalid Unicode escape : "
             "must be \\u HexDigit HexDigit HexDigit HexDigit");
         break;
     // backslash
@@ -225,14 +225,14 @@
     char_type ch_prev = char_type(), ch_next = char_type();
     bool have_prev = false;
 
- ensure(begin != end, error_brack, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_(begin != end, error_brack, "unexpected end of pattern found");
 
     // remember the current position and grab the next token
     iprev = begin;
     tok = traits.get_charset_token(begin, end);
     do
     {
- ensure(begin != end, error_brack, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_(begin != end, error_brack, "unexpected end of pattern found");
 
         if(token_charset_hyphen == tok && have_prev)
         {
@@ -248,19 +248,19 @@
                 begin = iprev2; // un-get these tokens and fall through
             case token_literal:
                 ch_next = *begin++;
- detail::ensure(ch_prev <= ch_next, error_range, "invalid charset range");
+ BOOST_XPR_ENSURE_(ch_prev <= ch_next, error_range, "invalid charset range");
                 chset.set_range(ch_prev, ch_next, rxtraits, icase);
                 continue;
             case token_charset_backspace:
                 ch_next = char_type(8); // backspace
- detail::ensure(ch_prev <= ch_next, error_range, "invalid charset range");
+ BOOST_XPR_ENSURE_(ch_prev <= ch_next, error_range, "invalid charset range");
                 chset.set_range(ch_prev, ch_next, rxtraits, icase);
                 continue;
             case token_escape:
                 esc = parse_escape(begin, end, traits);
                 if(escape_char == esc.type_)
                 {
- detail::ensure(ch_prev <= esc.ch_, error_range, "invalid charset range");
+ BOOST_XPR_ENSURE_(ch_prev <= esc.ch_, error_range, "invalid charset range");
                     chset.set_range(ch_prev, esc.ch_, rxtraits, icase);
                     continue;
                 }
@@ -306,12 +306,12 @@
                 while(token_literal == (tok = traits.get_charset_token(begin, end)))
                 {
                     tmp = ++begin;
- ensure(begin != end, error_brack, "unexpected end of pattern found");
+ BOOST_XPR_ENSURE_(begin != end, error_brack, "unexpected end of pattern found");
                 }
                 if(token_posix_charset_end == tok)
                 {
                     char_class_type chclass = rxtraits.lookup_classname(start, tmp, icase);
- ensure(0 != chclass, error_ctype, "unknown class name");
+ BOOST_XPR_ENSURE_(0 != chclass, error_ctype, "unknown class name");
                     chset.set_class(chclass, invert);
                     continue;
                 }
@@ -346,7 +346,7 @@
             continue;
         }
     }
- while(ensure((iprev = begin) != end, error_brack, "unexpected end of pattern found"),
+ while(BOOST_XPR_ENSURE_((iprev = begin) != end, error_brack, "unexpected end of pattern found"),
           token_charset_end != (tok = traits.get_charset_token(begin, end)));
 
     if(have_prev)

Modified: trunk/boost/xpressive/detail/dynamic/parser_traits.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/parser_traits.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/parser_traits.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -161,7 +161,7 @@
         case BOOST_XPR_CHAR_(char_type, '{'):
             old_begin = this->eat_ws_(++begin, end);
             spec.min_ = spec.max_ = detail::toi(begin, end, this->traits());
- detail::ensure
+ BOOST_XPR_ENSURE_
             (
                 begin != old_begin && begin != end, error_brace, "invalid quantifier"
             );
@@ -170,7 +170,7 @@
             {
                 old_begin = this->eat_ws_(++begin, end);
                 spec.max_ = detail::toi(begin, end, this->traits());
- detail::ensure
+ BOOST_XPR_ENSURE_
                 (
                     begin != end && BOOST_XPR_CHAR_(char_type, '}') == *begin
                   , error_brace, "invalid quantifier"
@@ -182,7 +182,7 @@
                 }
                 else
                 {
- detail::ensure
+ BOOST_XPR_ENSURE_
                     (
                         spec.min_ <= spec.max_, error_badbrace, "invalid quantification range"
                     );
@@ -190,7 +190,7 @@
             }
             else
             {
- detail::ensure
+ BOOST_XPR_ENSURE_
                 (
                     BOOST_XPR_CHAR_(char_type, '}') == *begin, error_brace, "invalid quantifier"
                 );
@@ -220,7 +220,7 @@
         if(this->eat_ws_(begin, end) != end && BOOST_XPR_CHAR_(char_type, '?') == *begin)
         {
             this->eat_ws_(++begin, end);
- detail::ensure(begin != end, error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(begin != end, error_paren, "incomplete extension");
 
             switch(*begin)
             {
@@ -232,7 +232,7 @@
             case BOOST_XPR_CHAR_(char_type, 'R'): ++begin; return token_recurse;
             case BOOST_XPR_CHAR_(char_type, '$'):
                 this->get_name_(++begin, end, name);
- detail::ensure(begin != end, error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(begin != end, error_paren, "incomplete extension");
                 if(BOOST_XPR_CHAR_(char_type, '=') == *begin)
                 {
                     ++begin;
@@ -242,30 +242,30 @@
 
             case BOOST_XPR_CHAR_(char_type, '<'):
                 this->eat_ws_(++begin, end);
- detail::ensure(begin != end, error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(begin != end, error_paren, "incomplete extension");
                 switch(*begin)
                 {
                 case BOOST_XPR_CHAR_(char_type, '='): ++begin; return token_positive_lookbehind;
                 case BOOST_XPR_CHAR_(char_type, '!'): ++begin; return token_negative_lookbehind;
                 default:
- boost::throw_exception(regex_error(error_badbrace, "unrecognized extension"));
+ BOOST_THROW_EXCEPTION(regex_error(error_badbrace, "unrecognized extension"));
                 }
 
             case BOOST_XPR_CHAR_(char_type, 'P'):
                 this->eat_ws_(++begin, end);
- detail::ensure(begin != end, error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(begin != end, error_paren, "incomplete extension");
                 switch(*begin)
                 {
                 case BOOST_XPR_CHAR_(char_type, '<'):
                     this->get_name_(++begin, end, name);
- detail::ensure(begin != end && BOOST_XPR_CHAR_(char_type, '>') == *begin++, error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(begin != end && BOOST_XPR_CHAR_(char_type, '>') == *begin++, error_paren, "incomplete extension");
                     return token_named_mark;
                 case BOOST_XPR_CHAR_(char_type, '='):
                     this->get_name_(++begin, end, name);
- detail::ensure(begin != end, error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(begin != end, error_paren, "incomplete extension");
                     return token_named_mark_ref;
                 default:
- boost::throw_exception(regex_error(error_badbrace, "unrecognized extension"));
+ BOOST_THROW_EXCEPTION(regex_error(error_badbrace, "unrecognized extension"));
                 }
 
             case BOOST_XPR_CHAR_(char_type, 'i'):
@@ -276,7 +276,7 @@
                 return this->parse_mods_(begin, end);
 
             default:
- boost::throw_exception(regex_error(error_badbrace, "unrecognized extension"));
+ BOOST_THROW_EXCEPTION(regex_error(error_badbrace, "unrecognized extension"));
             }
         }
 
@@ -301,13 +301,13 @@
                 FwdIter next = begin; ++next;
                 if(next != end)
                 {
- detail::ensure(
+ BOOST_XPR_ENSURE_(
                         *next != BOOST_XPR_CHAR_(char_type, '=')
                       , error_collate
                       , "equivalence classes are not yet supported"
                     );
 
- detail::ensure(
+ BOOST_XPR_ENSURE_(
                         *next != BOOST_XPR_CHAR_(char_type, '.')
                       , error_collate
                       , "collation sequences are not yet supported"
@@ -397,9 +397,9 @@
         case BOOST_XPR_CHAR_(char_type, ':'): ++begin; // fall-through
         case BOOST_XPR_CHAR_(char_type, ')'): return token_no_mark;
         case BOOST_XPR_CHAR_(char_type, '-'): if(false == (set = !set)) break; // else fall-through
- default: boost::throw_exception(regex_error(error_paren, "unknown pattern modifier"));
+ default: BOOST_THROW_EXCEPTION(regex_error(error_paren, "unknown pattern modifier"));
         }
- while(detail::ensure(++begin != end, error_paren, "incomplete extension"));
+ while(BOOST_XPR_ENSURE_(++begin != end, error_paren, "incomplete extension"));
         // this return is technically unreachable, but this must
         // be here to work around a bug in gcc 4.0
         return token_no_mark;
@@ -437,7 +437,7 @@
             name.push_back(*begin);
         }
         this->eat_ws_(begin, end);
- detail::ensure(!name.empty(), regex_constants::error_paren, "incomplete extension");
+ BOOST_XPR_ENSURE_(!name.empty(), regex_constants::error_paren, "incomplete extension");
     }
 
     ///////////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/xpressive/match_results.hpp
==============================================================================
--- trunk/boost/xpressive/match_results.hpp (original)
+++ trunk/boost/xpressive/match_results.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -102,7 +102,7 @@
     {
         if(numeric::cInRange != result)
         {
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
                 regex_error(
                     regex_constants::error_escape
                   , "character escape too large to fit in target character type"
@@ -801,7 +801,7 @@
                 return this->sub_matches_[ this->named_marks_[i].mark_nbr_ ];
             }
         }
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
             regex_error(regex_constants::error_badmark, "invalid named back-reference")
         );
         // Should never execute, but if it does, this returns
@@ -1032,7 +1032,7 @@
     {
         detail::case_converting_iterator<OutputIterator, char_type> iout(out, this->traits_.get());
         iout = this->format_all_impl_(cur, end, iout);
- detail::ensure(cur == end
+ BOOST_XPR_ENSURE_(cur == end
           , regex_constants::error_paren, "unbalanced parentheses in format string");
         return iout.base();
     }
@@ -1066,16 +1066,16 @@
 
             case BOOST_XPR_CHAR_(char_type, '('):
                 out = this->format_all_impl_(++cur, end, out);
- detail::ensure(BOOST_XPR_CHAR_(char_type, ')') == *(cur-1)
+ BOOST_XPR_ENSURE_(BOOST_XPR_CHAR_(char_type, ')') == *(cur-1)
                   , regex_constants::error_paren, "unbalanced parentheses in format string");
                 break;
 
             case BOOST_XPR_CHAR_(char_type, '?'):
- detail::ensure(++cur != end
+ BOOST_XPR_ENSURE_(++cur != end
                   , regex_constants::error_subreg, "malformed conditional in format string");
                 max = static_cast<int>(this->size() - 1);
                 sub = detail::toi(cur, end, *this->traits_, 10, max);
- detail::ensure(0 != sub, regex_constants::error_subreg, "invalid back-reference");
+ BOOST_XPR_ENSURE_(0 != sub, regex_constants::error_subreg, "invalid back-reference");
                 if(this->sub_matches_[ sub ].matched)
                 {
                     out = this->format_all_impl_(cur, end, out, true);
@@ -1145,7 +1145,7 @@
         {
             int max = static_cast<int>(this->size() - 1);
             int sub = detail::toi(cur, end, *this->traits_, 10, max);
- detail::ensure(0 != sub, regex_constants::error_subreg, "invalid back-reference");
+ BOOST_XPR_ENSURE_(0 != sub, regex_constants::error_subreg, "invalid back-reference");
             if(this->sub_matches_[ sub ].matched)
                 out = std::copy(this->sub_matches_[ sub ].first, this->sub_matches_[ sub ].second, out);
         }
@@ -1214,27 +1214,27 @@
             break;
 
         case BOOST_XPR_CHAR_(char_type, 'x'):
- detail::ensure(cur != end, error_escape, "unexpected end of format found");
+ BOOST_XPR_ENSURE_(cur != end, error_escape, "unexpected end of format found");
             if(BOOST_XPR_CHAR_(char_type, '{') == *cur)
             {
- detail::ensure(++cur != end, error_escape, "unexpected end of format found");
+ BOOST_XPR_ENSURE_(++cur != end, error_escape, "unexpected end of format found");
                 tmp = cur;
                 *out++ = converter(detail::toi(cur, end, *this->traits_, 16, 0xffff));
- detail::ensure(4 == std::distance(tmp, cur) && cur != end && BOOST_XPR_CHAR_(char_type, '}') == *cur++
+ BOOST_XPR_ENSURE_(4 == std::distance(tmp, cur) && cur != end && BOOST_XPR_CHAR_(char_type, '}') == *cur++
                   , error_escape, "invalid hex escape : must be \\x { HexDigit HexDigit HexDigit HexDigit }");
             }
             else
             {
                 tmp = cur;
                 *out++ = converter(detail::toi(cur, end, *this->traits_, 16, 0xff));
- detail::ensure(2 == std::distance(tmp, cur), error_escape
+ BOOST_XPR_ENSURE_(2 == std::distance(tmp, cur), error_escape
                   , "invalid hex escape : must be \\x HexDigit HexDigit");
             }
             break;
 
         case BOOST_XPR_CHAR_(char_type, 'c'):
- detail::ensure(cur != end, error_escape, "unexpected end of format found");
- detail::ensure
+ BOOST_XPR_ENSURE_(cur != end, error_escape, "unexpected end of format found");
+ BOOST_XPR_ENSURE_
             (
                 this->traits_->in_range(BOOST_XPR_CHAR_(char_type, 'a'), BOOST_XPR_CHAR_(char_type, 'z'), *cur)
              || this->traits_->in_range(BOOST_XPR_CHAR_(char_type, 'A'), BOOST_XPR_CHAR_(char_type, 'Z'), *cur)
@@ -1310,12 +1310,12 @@
     ) const
     {
         using namespace regex_constants;
- detail::ensure(cur != end && BOOST_XPR_CHAR_(char_type, '<') == *cur++
+ BOOST_XPR_ENSURE_(cur != end && BOOST_XPR_CHAR_(char_type, '<') == *cur++
             , error_badmark, "invalid named back-reference");
         ForwardIterator begin = cur;
         for(; cur != end && BOOST_XPR_CHAR_(char_type, '>') != *cur; ++cur)
         {}
- detail::ensure(cur != begin && cur != end && BOOST_XPR_CHAR_(char_type, '>') == *cur
+ BOOST_XPR_ENSURE_(cur != begin && cur != end && BOOST_XPR_CHAR_(char_type, '>') == *cur
             , error_badmark, "invalid named back-reference");
 
         string_type name(begin, cur++);
@@ -1328,7 +1328,7 @@
             }
         }
 
- boost::throw_exception(regex_error(error_badmark, "invalid named back-reference"));
+ BOOST_THROW_EXCEPTION(regex_error(error_badmark, "invalid named back-reference"));
         // Should never get here
         return out;
     }

Modified: trunk/boost/xpressive/regex_actions.hpp
==============================================================================
--- trunk/boost/xpressive/regex_actions.hpp (original)
+++ trunk/boost/xpressive/regex_actions.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -615,25 +615,25 @@
 
             void operator()() const
             {
- boost::throw_exception(Except());
+ BOOST_THROW_EXCEPTION(Except());
             }
 
             template<typename A0>
             void operator()(A0 const &a0) const
             {
- boost::throw_exception(Except(a0));
+ BOOST_THROW_EXCEPTION(Except(a0));
             }
 
             template<typename A0, typename A1>
             void operator()(A0 const &a0, A1 const &a1) const
             {
- boost::throw_exception(Except(a0, a1));
+ BOOST_THROW_EXCEPTION(Except(a0, a1));
             }
 
             template<typename A0, typename A1, typename A2>
             void operator()(A0 const &a0, A1 const &a1, A2 const &a2) const
             {
- boost::throw_exception(Except(a0, a1, a2));
+ BOOST_THROW_EXCEPTION(Except(a0, a1, a2));
             }
         };
     }

Modified: trunk/boost/xpressive/regex_compiler.hpp
==============================================================================
--- trunk/boost/xpressive/regex_compiler.hpp (original)
+++ trunk/boost/xpressive/regex_compiler.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -193,11 +193,11 @@
         // Check if this regex is a named rule:
         string_type name;
         if(token_group_begin == this->traits_.get_token(tmp, end) &&
- detail::ensure(tmp != end, error_paren, "mismatched parenthesis") &&
+ BOOST_XPR_ENSURE_(tmp != end, error_paren, "mismatched parenthesis") &&
            token_rule_assign == this->traits_.get_group_type(tmp, end, name))
         {
             begin = tmp;
- detail::ensure
+ BOOST_XPR_ENSURE_
             (
                 begin != end && token_group_end == this->traits_.get_token(begin, end)
               , error_paren
@@ -210,7 +210,7 @@
 
         // at the top level, a regex is a sequence of alternates
         detail::sequence<BidiIter> seq = this->parse_alternates(begin, end);
- detail::ensure(begin == end, error_paren, "mismatched parenthesis");
+ BOOST_XPR_ENSURE_(begin == end, error_paren, "mismatched parenthesis");
 
         // terminate the sequence
         seq += detail::make_dynamic<BidiIter>(detail::end_matcher());
@@ -338,12 +338,12 @@
             break;
 
         case token_comment:
- while(detail::ensure(begin != end, error_paren, "mismatched parenthesis"))
+ while(BOOST_XPR_ENSURE_(begin != end, error_paren, "mismatched parenthesis"))
             {
                 switch(this->traits_.get_token(begin, end))
                 {
                 case token_group_end: return this->parse_atom(begin, end);
- case token_escape: detail::ensure(begin != end, error_escape, "incomplete escape sequence");
+ case token_escape: BOOST_XPR_ENSURE_(begin != end, error_escape, "incomplete escape sequence");
                 case token_literal: ++begin;
                 default:;
                 }
@@ -351,7 +351,7 @@
             break;
 
         case token_recurse:
- detail::ensure
+ BOOST_XPR_ENSURE_
             (
                 begin != end && token_group_end == this->traits_.get_token(begin, end)
               , error_paren
@@ -360,7 +360,7 @@
             return detail::make_dynamic<BidiIter>(detail::regex_byref_matcher<BidiIter>(this->self_));
 
         case token_rule_assign:
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
                 regex_error(error_badrule, "rule assignments must be at the front of the regex")
             );
             break;
@@ -368,7 +368,7 @@
         case token_rule_ref:
             {
                 typedef detail::core_access<BidiIter> access;
- detail::ensure
+ BOOST_XPR_ENSURE_
                 (
                     begin != end && token_group_end == this->traits_.get_token(begin, end)
                   , error_paren
@@ -384,7 +384,7 @@
             mark_nbr = static_cast<int>(++this->mark_count_);
             for(std::size_t i = 0; i < this->self_->named_marks_.size(); ++i)
             {
- detail::ensure(this->self_->named_marks_[i].name_ != name, error_badmark, "named mark already exists");
+ BOOST_XPR_ENSURE_(this->self_->named_marks_[i].name_ != name, error_badmark, "named mark already exists");
             }
             this->self_->named_marks_.push_back(detail::named_mark<char_type>(name, this->mark_count_));
             seq = detail::make_dynamic<BidiIter>(detail::mark_begin_matcher(mark_nbr));
@@ -392,7 +392,7 @@
             break;
 
         case token_named_mark_ref:
- detail::ensure
+ BOOST_XPR_ENSURE_
             (
                 begin != end && token_group_end == this->traits_.get_token(begin, end)
               , error_paren
@@ -409,7 +409,7 @@
                     );
                 }
             }
- boost::throw_exception(regex_error(error_badmark, "invalid named back-reference"));
+ BOOST_THROW_EXCEPTION(regex_error(error_badmark, "invalid named back-reference"));
             break;
 
         default:
@@ -422,7 +422,7 @@
         // alternates
         seq += this->parse_alternates(begin, end);
         seq += seq_end;
- detail::ensure
+ BOOST_XPR_ENSURE_
         (
             begin != end && token_group_end == this->traits_.get_token(begin, end)
           , error_paren
@@ -549,7 +549,7 @@
             return this->parse_charset(begin, end);
 
         case token_invalid_quantifier:
- boost::throw_exception(regex_error(error_badrepeat, "quantifier not expected"));
+ BOOST_THROW_EXCEPTION(regex_error(error_badrepeat, "quantifier not expected"));
             break;
 
         case token_quote_meta_begin:
@@ -559,7 +559,7 @@
             );
 
         case token_quote_meta_end:
- boost::throw_exception(
+ BOOST_THROW_EXCEPTION(
                 regex_error(
                     error_escape
                   , "found quote-meta end without corresponding quote-meta begin"
@@ -689,7 +689,7 @@
             switch(this->traits_.get_token(begin, end))
             {
             case token_quote_meta_end: return string_type(old_begin, old_end);
- case token_escape: detail::ensure(begin != end, error_escape, "incomplete escape sequence");
+ case token_escape: BOOST_XPR_ENSURE_(begin != end, error_escape, "incomplete escape sequence");
             case token_literal: ++begin;
             default:;
             }
@@ -703,7 +703,7 @@
     template<typename FwdIter>
     escape_value parse_escape(FwdIter &begin, FwdIter end)
     {
- detail::ensure(begin != end, regex_constants::error_escape, "incomplete escape sequence");
+ BOOST_XPR_ENSURE_(begin != end, regex_constants::error_escape, "incomplete escape sequence");
 
         // first, check to see if this can be a backreference
         if(0 < this->rxtraits().value(*begin, 10))

Modified: trunk/boost/xpressive/regex_error.hpp
==============================================================================
--- trunk/boost/xpressive/regex_error.hpp (original)
+++ trunk/boost/xpressive/regex_error.hpp 2008-10-22 15:17:43 EDT (Wed, 22 Oct 2008)
@@ -17,6 +17,7 @@
 #include <string>
 #include <stdexcept>
 #include <boost/throw_exception.hpp>
+#include <boost/exception/exception.hpp>
 #include <boost/xpressive/regex_constants.hpp>
 
 //{{AFX_DOC_COMMENT
@@ -44,12 +45,14 @@
 /// a regular expression to a finite state machine.
 struct regex_error
   : std::runtime_error
+ , boost::exception
 {
     /// Constructs an object of class regex_error.
     /// \param code The error_type this regex_error represents.
     /// \post code() == code
     explicit regex_error(regex_constants::error_type code, char const *str = "")
       : std::runtime_error(str)
+ , boost::exception()
       , code_(code)
     {
     }
@@ -69,19 +72,21 @@
 
 namespace detail
 {
-
-//////////////////////////////////////////////////////////////////////////
-// ensure
-/// INTERNAL ONLY
-inline bool ensure(bool predicate, regex_constants::error_type code, char const *str = "")
-{
- if(!predicate)
- {
- boost::throw_exception(regex_error(code, str));
- }
- return predicate;
+ // To work around a GCC warning
+ inline bool false_() { return false; }
 }
 
-}}} // namespace boost::xpressive::detail
+#define BOOST_XPR_ENSURE_(pred, code, msg) \
+ ( \
+ (pred) \
+ ? true \
+ : ( \
+ BOOST_THROW_EXCEPTION(boost::xpressive::regex_error(code, msg)) \
+ , boost::xpressive::detail::false_() \
+ ) \
+ ) \
+ /**/
+
+}} // namespace boost::xpressive
 
 #endif


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