]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/regex.hpp
complie fix
[lyx.git] / boost / boost / regex.hpp
index 070abda84a682bef9265b4b89cea20b45679c8d2..c1313958124565f029f47993b8368dfc5cbbbc7f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *
- * Copyright (c) 1998-2000
+ * Copyright (c) 1998-2002
  * Dr John Maddock
  *
  * Permission to use, copy, modify, distribute and sell this software
  /*
   *   LOCATION:    see http://www.boost.org for most recent version.
   *   FILE         regex.cpp
-  *   VERSION      3.03
+  *   VERSION      see <boost/version.hpp>
   *   DESCRIPTION: Declares boost::reg_expression<> and associated
   *                functions and classes. This header is the main
   *                entry point for the template regex code.
   */
 
 
-/* start with C compatability API */
+/* start with C compatibility API */
 
 #ifndef BOOST_RE_REGEX_HPP
 #define BOOST_RE_REGEX_HPP
 
 // what follows is all C++ don't include in C builds!!
 
-#ifdef BOOST_RE_DEBUG
+#ifdef BOOST_REGEX_DEBUG
 # include <iosfwd>
 #endif
 
 #include <new>
-#include <boost/re_detail/regex_config.hpp>
-#if !defined(BOOST_RE_NO_TYPEINFO)
-#include <typeinfo>
-#endif
+#include <boost/regex/config.hpp>
 #include <cstring>
-#include <boost/re_detail/regex_stack.hpp>
-#include <boost/re_detail/regex_raw_buffer.hpp>
-#include <boost/re_detail/regex_kmp.hpp>
-#include <boost/pattern_except.hpp>
-#include <boost/regex_traits.hpp>
-#include <boost/type_traits.hpp>
+#include <boost/regex_fwd.hpp>
+#include <boost/regex/detail/regex_stack.hpp>
+#include <boost/regex/detail/regex_raw_buffer.hpp>
+#include <boost/regex/detail/regex_kmp.hpp>
+#include <boost/regex/pattern_except.hpp>
+#include <boost/regex/regex_traits.hpp>
+#include <boost/type_traits/cv_traits.hpp>
+#include <boost/scoped_array.hpp>
 
 
 namespace boost{
 
 #ifdef __BORLANDC__
-   #if __BORLANDC__ == 0x530
-    #pragma option push -a4 -b -Ve
-   #elif __BORLANDC__ > 0x530
-    #pragma option push -a8 -b -Ve
-   #endif
+   #pragma option push -a8 -b -Vx -Ve -pc -w-8027
 #endif
 
 namespace re_detail{
@@ -85,13 +80,13 @@ public:
    typedef unsigned int size_type;
    typedef regex_traits<char> base_type;
 
-   char BOOST_RE_CALL translate(char c, bool)const
+   char BOOST_REGEX_CALL translate(char c, bool)const
    {
       return static_cast<const regex_traits<char>*>(this)->translate(c, true);
    }
 };
 
-#ifndef BOOST_RE_NO_WCSTRING
+#ifndef BOOST_NO_WREGEX
 template<>
 class char_regex_traits_i<wchar_t> : public regex_traits<wchar_t>
 {
@@ -101,13 +96,13 @@ public:
    typedef unsigned int size_type;
    typedef regex_traits<wchar_t> base_type;
 
-   wchar_t BOOST_RE_CALL translate(wchar_t c, bool)const
+   wchar_t BOOST_REGEX_CALL translate(wchar_t c, bool)const
    {
       return static_cast<const regex_traits<wchar_t>*>(this)->translate(c, true);
    }
-   jm_uintfast32_t BOOST_RE_CALL lookup_classname(const wchar_t* first, const wchar_t* last)const
+   boost::uint_fast32_t BOOST_REGEX_CALL lookup_classname(const wchar_t* first, const wchar_t* last)const
    {
-      jm_uintfast32_t result = static_cast<const regex_traits<wchar_t>*>(this)->lookup_classname(first, last);
+      boost::uint_fast32_t result = static_cast<const regex_traits<wchar_t>*>(this)->lookup_classname(first, last);
       if((result & base_type::char_class_upper) == base_type::char_class_upper)
          result |= base_type::char_class_alpha;
       return result;
@@ -197,7 +192,7 @@ enum syntax_element_type
    syntax_element_restart_continue = syntax_element_soft_buffer_end + 1
 };
 
-#ifdef BOOST_RE_DEBUG
+#ifdef BOOST_REGEX_DEBUG
 // dwa 09/26/00 - This is needed to suppress warnings about an ambiguous conversion
 std::ostream& operator<<(std::ostream&, syntax_element_type);
 #endif
@@ -205,7 +200,7 @@ std::ostream& operator<<(std::ostream&, syntax_element_type);
 union offset_type
 {
    re_syntax_base* p;
-   unsigned i;
+   std::size_t i;
 };
 
 //
@@ -223,7 +218,7 @@ struct re_syntax_base
 // marks start or end of (...)
 struct re_brace : public re_syntax_base
 {
-   unsigned int index;
+   int index;
 };
 
 //
@@ -242,7 +237,7 @@ struct re_literal : public re_syntax_base
 struct re_set_long : public re_syntax_base
 {
    unsigned int csingles, cranges, cequivalents;
-   jm_uintfast32_t cclasses;
+   boost::uint_fast32_t cclasses;
    bool isnot;
 };
 
@@ -273,6 +268,7 @@ struct re_repeat : public re_jump
    int id;
    bool leading;
    bool greedy;
+   bool singleton;
 };
 
 
@@ -294,7 +290,7 @@ enum re_jump_size_type
 // class basic_regex
 // handles error codes and flags
 
-class BOOST_RE_IX_DECL regbase
+class BOOST_REGEX_DECL regbase
 {
 public:
    enum flag_type_
@@ -339,7 +335,7 @@ public:
       restart_fixed_lit = 6
    };
 
-   flag_type BOOST_RE_CALL flags()const
+   flag_type BOOST_REGEX_CALL flags()const
    {
       return _flags;
    }
@@ -363,7 +359,7 @@ struct regex_iterator_traits
 {
   typedef typename T::iterator_category iterator_category;
   typedef typename T::value_type        value_type;
-#ifndef BOOST_MSVC
+#if !defined(BOOST_NO_STD_ITERATOR)
   typedef typename T::difference_type   difference_type;
   typedef typename T::pointer           pointer;
   typedef typename T::reference         reference;
@@ -407,7 +403,7 @@ template<>
 struct regex_iterator_traits<std::string::iterator> : pointer_iterator_traits<char>{};
 template<>
 struct regex_iterator_traits<std::string::const_iterator> : const_pointer_iterator_traits<char>{};
-#ifndef BOOST_NO_WSTRING
+#ifndef BOOST_NO_STD_WSTRING
 template<>
 struct regex_iterator_traits<std::wstring::iterator> : pointer_iterator_traits<wchar_t>{};
 template<>
@@ -428,10 +424,25 @@ struct def_alloc_param_traits
    typedef typename regex_iterator_traits<I>::value_type const_value_type;
    typedef typename remove_cv<const_value_type>::type type;
 };
+template <>
+struct def_alloc_param_traits<const char*>
+{
+   typedef char type;
+};
+template <>
+struct def_alloc_param_traits<const wchar_t*>
+{
+   typedef wchar_t type;
+};
 
 }
 
-template <class iterator, class Allocator BOOST_RE_DEF_ALLOC_PARAM(typename re_detail::def_alloc_param_traits<iterator>::type) >
+template <class iterator, class Allocator =
+#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))
+BOOST_DEFAULT_ALLOCATOR(typename re_detail::def_alloc_param_traits<iterator>::type) >
+#else
+BOOST_DEFAULT_ALLOCATOR(re_detail::def_alloc_param_traits<iterator>::type) >
+#endif
 class match_results;
 
 //
@@ -440,22 +451,22 @@ class match_results;
 // regular expression:
 //
 
-#if defined(BOOST_RE_NO_TEMPLATE_SWITCH_MERGE) && !defined(BOOST_RE_NO_NAMESPACES)
-//
-// Ugly ugly hack, 
-// template don't merge if they contain switch statements so declare these
-// templates in unnamed namespace (ie with internal linkage), each translation
-// unit then gets its own local copy, it works seemlessly but bloats the app.
-namespace{
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable : 4251 4231 4660)
 #endif
 
-template <class charT, class traits BOOST_RE_TRICKY_DEFAULT_PARAM(regex_traits<charT>), class Allocator BOOST_RE_DEF_ALLOC_PARAM(charT) >
+#ifdef BOOST_REGEX_NO_FWD
+template <class charT, class traits = regex_traits<charT>, class Allocator = BOOST_DEFAULT_ALLOCATOR(charT) >
+#else
+template <class charT, class traits, class Allocator >
+#endif
 class reg_expression : public regbase
 {
+public:
    typedef typename traits::size_type traits_size_type;
    typedef typename traits::uchar_type traits_uchar_type;
    typedef typename traits::string_type traits_string_type;
-public:
    // typedefs:
    typedef charT char_type;
    typedef traits traits_type;
@@ -489,8 +500,8 @@ public:
    reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a = Allocator());
    reg_expression(const reg_expression&);
    ~reg_expression();
-   reg_expression& BOOST_RE_CALL operator=(const reg_expression&);
-   reg_expression& BOOST_RE_CALL operator=(const charT* ptr)
+   reg_expression& BOOST_REGEX_CALL operator=(const reg_expression&);
+   reg_expression& BOOST_REGEX_CALL operator=(const charT* ptr)
    {
       set_expression(ptr, regbase::normal | regbase::use_except);
       return *this;
@@ -513,19 +524,19 @@ public:
       set_expression(first, last, f | regbase::use_except);
       return *this;
    }
-#ifndef BOOST_RE_NO_MEMBER_TEMPLATES
+#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !(defined(__IBMCPP__) && (__IBMCPP__ <= 502))
 
    template <class ST, class SA>
-   unsigned int BOOST_RE_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal)
+   unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal)
    { return set_expression(p.data(), p.data() + p.size(), f); }
 
    template <class ST, class SA>
    explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
-    : data(a), pkmp(0) { set_expression(p, f); }
+    : data(a), pkmp(0), error_code_(REG_EMPTY), _expression(0) { set_expression(p, f | regbase::use_except); }
 
    template <class I>
    reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator())
-    : data(al), pkmp(0)
+    : data(al), pkmp(0), error_code_(REG_EMPTY), _expression(0)
    {
       size_type len = last-first;
       scoped_array<charT> a(new charT[len]);
@@ -534,14 +545,14 @@ public:
    }
 
    template <class ST, class SA>
-   reg_expression& BOOST_RE_CALL operator=(const std::basic_string<charT, ST, SA>& p)
+   reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
    {
       set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
       return *this;
    }
 
    template <class string_traits, class A>
-   reg_expression& BOOST_RE_CALL assign(
+   reg_expression& BOOST_REGEX_CALL assign(
        const std::basic_string<charT, string_traits, A>& s,
        flag_type f = regbase::normal)
    {
@@ -550,7 +561,7 @@ public:
    }
 
    template <class fwd_iterator>
-   reg_expression& BOOST_RE_CALL assign(fwd_iterator first,
+   reg_expression& BOOST_REGEX_CALL assign(fwd_iterator first,
                           fwd_iterator last,
                           flag_type f = regbase::normal)
    {
@@ -560,20 +571,20 @@ public:
       set_expression(a.get(), a.get() + len, f | regbase::use_except);
       return *this;
    }
-#elif !defined(BOOST_RE_NO_STRING_DEF_ARGS)
-   unsigned int BOOST_RE_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal)
-   { return set_expression(p.data(), p.data() + p.size(), f); }
+#else
+   unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal)
+   { return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); }
 
    reg_expression(const std::basic_string<charT>& p, flag_type f = regbase::normal, const Allocator& a = Allocator())
-    : data(a), pkmp(0) { set_expression(p, f); }
+    : data(a), pkmp(0) { set_expression(p, f | regbase::use_except); }
 
-   reg_expression& BOOST_RE_CALL operator=(const std::basic_string<charT>& p)
+   reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
    {
       set_expression(p.c_str(), p.c_str() + p.size(), regbase::normal | regbase::use_except);
       return *this;
    }
 
-   reg_expression& BOOST_RE_CALL assign(
+   reg_expression& BOOST_REGEX_CALL assign(
        const std::basic_string<charT>& s,
        flag_type f = regbase::normal)
    {
@@ -586,114 +597,123 @@ public:
 
    //
    // allocator access:
-   Allocator BOOST_RE_CALL get_allocator()const;
+   Allocator BOOST_REGEX_CALL get_allocator()const;
    //
    // locale:
-   locale_type BOOST_RE_CALL imbue(locale_type l){ return traits_inst.imbue(l); }
-   locale_type BOOST_RE_CALL getloc()const{ return traits_inst.getloc(); }
+   locale_type BOOST_REGEX_CALL imbue(locale_type l){ return traits_inst.imbue(l); }
+   locale_type BOOST_REGEX_CALL getloc()const{ return traits_inst.getloc(); }
    //
    // flags:
-   flag_type BOOST_RE_CALL getflags()const
+   flag_type BOOST_REGEX_CALL getflags()const
    { return flags(); }
    //
    // str:
-   std::basic_string<charT> BOOST_RE_CALL str()const
-   { return std::basic_string<charT>(_expression, _expression_len); }
+   std::basic_string<charT> BOOST_REGEX_CALL str()const
+   {
+      std::basic_string<charT> result;
+      if(this->error_code() == 0)
+         result = std::basic_string<charT>(_expression, _expression_len);
+      return result;
+   }
    //
    // begin, end:
-   const_iterator BOOST_RE_CALL begin()const
-   { return _expression; }
-   const_iterator BOOST_RE_CALL end()const
-   { return _expression + _expression_len; }
+   const_iterator BOOST_REGEX_CALL begin()const
+   { return (this->error_code() ? 0 : _expression); }
+   const_iterator BOOST_REGEX_CALL end()const
+   { return (this->error_code() ? 0 : _expression + _expression_len); }
    //
    // swap:
-   void BOOST_RE_CALL swap(reg_expression&)throw();
+   void BOOST_REGEX_CALL swap(reg_expression&)throw();
    //
    // size:
-   size_type BOOST_RE_CALL size()const
-   { return _expression_len; }
+   size_type BOOST_REGEX_CALL size()const
+   { return (this->error_code() ? 0 : _expression_len); }
    //
    // max_size:
-   size_type BOOST_RE_CALL max_size()const
+   size_type BOOST_REGEX_CALL max_size()const
    { return UINT_MAX; }
    //
    // empty:
-   bool BOOST_RE_CALL empty()const
-   { return this->error_code(); }
+   bool BOOST_REGEX_CALL empty()const
+   { return 0 != this->error_code(); }
 
-   unsigned BOOST_RE_CALL mark_count()const { return marks; }
-   bool BOOST_RE_CALL operator==(const reg_expression&)const;
-   bool BOOST_RE_CALL operator<(const reg_expression&)const;
+   unsigned BOOST_REGEX_CALL mark_count()const { return (this->error_code() ? 0 : marks); }
+   bool BOOST_REGEX_CALL operator==(const reg_expression&)const;
+   bool BOOST_REGEX_CALL operator<(const reg_expression&)const;
    //
    // The following are deprecated as public interfaces
-   // but are available for compatability with earlier versions.
-   allocator_type BOOST_RE_CALL allocator()const;
-   const charT* BOOST_RE_CALL expression()const { return _expression; }
-   unsigned int BOOST_RE_CALL set_expression(const charT* p, const charT* end, flag_type f = regbase::normal);
-   unsigned int BOOST_RE_CALL set_expression(const charT* p, flag_type f = regbase::normal) { return set_expression(p, p + traits_type::length(p), f); }
+   // but are available for compatibility with earlier versions.
+   allocator_type BOOST_REGEX_CALL allocator()const;
+   const charT* BOOST_REGEX_CALL expression()const { return (this->error_code() ? 0 : _expression); }
+   unsigned int BOOST_REGEX_CALL set_expression(const charT* p, const charT* end, flag_type f = regbase::normal);
+   unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regbase::normal) { return set_expression(p, p + traits_type::length(p), f); }
    //
    // this should be private but template friends don't work:
    const traits_type& get_traits()const { return traits_inst; }
-   unsigned int BOOST_RE_CALL error_code()const
+   unsigned int BOOST_REGEX_CALL error_code()const
    {
       return error_code_;
    }
 
 private:
+   traits_type traits_inst;
    re_detail::raw_storage<Allocator> data;
    unsigned _restart_type;
    unsigned marks;
    int repeats;
    unsigned char* startmap;
-   charT* _expression;
-   unsigned _expression_len;
-   unsigned int _leading_len;
+   std::size_t _expression_len;
+   std::size_t _leading_len;
    const charT* _leading_string;
-   unsigned int _leading_string_len;
+   std::size_t _leading_string_len;
    re_detail::kmp_info<charT>* pkmp;
-   traits_type traits_inst;
    unsigned error_code_;
+   charT* _expression;
 
-   void BOOST_RE_CALL compile_maps();
-   void BOOST_RE_CALL compile_map(re_detail::re_syntax_base* node, unsigned char* _map, unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal = NULL)const;
-   bool BOOST_RE_CALL probe_start(re_detail::re_syntax_base* node, charT c, re_detail::re_syntax_base* terminal)const;
-   bool BOOST_RE_CALL probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const;
-   void BOOST_RE_CALL fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces);
-   void BOOST_RE_CALL move_offsets(re_detail::re_syntax_base* j, unsigned size);
-   re_detail::re_syntax_base* BOOST_RE_CALL compile_set(const charT*& first, const charT* last);
-   re_detail::re_syntax_base* BOOST_RE_CALL compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<jm_uintfast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_narrow_type&);
-   re_detail::re_syntax_base* BOOST_RE_CALL compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<jm_uintfast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_wide_type&);
-   re_detail::re_syntax_base* BOOST_RE_CALL compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot = false);
-   unsigned int BOOST_RE_CALL parse_inner_set(const charT*& first, const charT* last);
-
-   re_detail::re_syntax_base* BOOST_RE_CALL add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size = sizeof(re_detail::re_syntax_base));
-   re_detail::re_syntax_base* BOOST_RE_CALL add_literal(re_detail::re_syntax_base* dat, charT c);
-   charT BOOST_RE_CALL parse_escape(const charT*& first, const charT* last);
-   void BOOST_RE_CALL parse_range(const charT*& first, const charT* last, unsigned& min, unsigned& max);
-   bool BOOST_RE_CALL skip_space(const charT*& first, const charT* last);
-   unsigned int BOOST_RE_CALL probe_restart(re_detail::re_syntax_base* dat);
-   unsigned int BOOST_RE_CALL fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end);
-   void BOOST_RE_CALL fail(unsigned int err);
+   void BOOST_REGEX_CALL compile_maps();
+   void BOOST_REGEX_CALL compile_map(re_detail::re_syntax_base* node, unsigned char* _map, unsigned int* pnull, unsigned char mask, re_detail::re_syntax_base* terminal = 0)const;
+   bool BOOST_REGEX_CALL probe_start(re_detail::re_syntax_base* node, charT c, re_detail::re_syntax_base* terminal)const;
+   bool BOOST_REGEX_CALL probe_start_null(re_detail::re_syntax_base* node, re_detail::re_syntax_base* terminal)const;
+   void BOOST_REGEX_CALL fixup_apply(re_detail::re_syntax_base* b, unsigned cbraces);
+   void BOOST_REGEX_CALL move_offsets(re_detail::re_syntax_base* j, unsigned size);
+   re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set(const charT*& first, const charT* last);
+   re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<boost::uint_fast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_narrow_type&);
+   re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<boost::uint_fast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_wide_type&);
+   re_detail::re_syntax_base* BOOST_REGEX_CALL compile_set_simple(re_detail::re_syntax_base* dat, unsigned long cls, bool isnot = false);
+   unsigned int BOOST_REGEX_CALL parse_inner_set(const charT*& first, const charT* last);
+
+   re_detail::re_syntax_base* BOOST_REGEX_CALL add_simple(re_detail::re_syntax_base* dat, re_detail::syntax_element_type type, unsigned int size = sizeof(re_detail::re_syntax_base));
+   re_detail::re_syntax_base* BOOST_REGEX_CALL add_literal(re_detail::re_syntax_base* dat, charT c);
+   charT BOOST_REGEX_CALL parse_escape(const charT*& first, const charT* last);
+   void BOOST_REGEX_CALL parse_range(const charT*& first, const charT* last, unsigned& min, unsigned& max);
+   bool BOOST_REGEX_CALL skip_space(const charT*& first, const charT* last);
+   unsigned int BOOST_REGEX_CALL probe_restart(re_detail::re_syntax_base* dat);
+   unsigned int BOOST_REGEX_CALL fixup_leading_rep(re_detail::re_syntax_base* dat, re_detail::re_syntax_base* end);
+   void BOOST_REGEX_CALL fail(unsigned int err);
 
 protected:
-   static int BOOST_RE_CALL repeat_count(const reg_expression& e)
+   static int BOOST_REGEX_CALL repeat_count(const reg_expression& e)
    { return e.repeats; }
-   static unsigned int BOOST_RE_CALL restart_type(const reg_expression& e)
+   static unsigned int BOOST_REGEX_CALL restart_type(const reg_expression& e)
    { return e._restart_type; }
-   static const re_detail::re_syntax_base* BOOST_RE_CALL first(const reg_expression& e)
+   static const re_detail::re_syntax_base* BOOST_REGEX_CALL first(const reg_expression& e)
    { return (const re_detail::re_syntax_base*)e.data.data(); }
-   static const unsigned char* BOOST_RE_CALL get_map(const reg_expression& e)
+   static const unsigned char* BOOST_REGEX_CALL get_map(const reg_expression& e)
    { return e.startmap; }
-   static unsigned int BOOST_RE_CALL leading_length(const reg_expression& e)
+   static std::size_t BOOST_REGEX_CALL leading_length(const reg_expression& e)
    { return e._leading_len; }
    static const re_detail::kmp_info<charT>* get_kmp(const reg_expression& e)
    { return e.pkmp; }
-   static bool BOOST_RE_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&);
-   static bool BOOST_RE_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&);
+   static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&);
+   static bool BOOST_REGEX_CALL can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_narrow_type&);
 };
 
+#ifdef BOOST_MSVC
+#pragma warning (pop)
+#endif
+
 template <class charT, class traits, class Allocator>
-void BOOST_RE_CALL reg_expression<charT, traits, Allocator>::swap(reg_expression& that)throw()
+inline void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::swap(reg_expression& that)throw()
 {
    // this is not as efficient as it should be,
    // however swapping traits classes is problematic
@@ -704,10 +724,6 @@ void BOOST_RE_CALL reg_expression<charT, traits, Allocator>::swap(reg_expression
 }
 
 
-#if defined(BOOST_RE_NO_TEMPLATE_SWITCH_MERGE) && !defined(BOOST_RE_NO_NAMESPACES)
-} // namespace
-#endif
-
 //
 // class match_results and match_results_base
 // handles what matched where
@@ -730,8 +746,7 @@ struct sub_match
    operator std::basic_string<value_type> ()const
    {
       std::basic_string<value_type> result;
-      unsigned len;
-      BOOST_RE_DISTANCE((iterator)first, (iterator)second, len);
+      std::size_t len = boost::re_detail::distance((iterator)first, (iterator)second);
       result.reserve(len);
       iterator i = first;
       while(i != second)
@@ -763,13 +778,12 @@ struct sub_match
    {
       return (first == that.first) && (second == that.second) && (matched == that.matched);
    }
-   bool BOOST_RE_CALL operator !=(const sub_match& that)const
+   bool BOOST_REGEX_CALL operator !=(const sub_match& that)const
    { return !(*this == that); }
 
-   difference_type BOOST_RE_CALL length()const
+   difference_type BOOST_REGEX_CALL length()const
    {
-      difference_type n;
-      BOOST_RE_DISTANCE((iterator)first, (iterator)second, n);
+      difference_type n = boost::re_detail::distance((iterator)first, (iterator)second);
       return n;
    }
 };
@@ -782,7 +796,10 @@ int do_toi(iterator i, iterator j, char c, int radix)
    std::string s(i, j);
    char* p;
    int result = std::strtol(s.c_str(), &p, radix);
+#ifndef BOOST_NO_EXCEPTIONS
    if(*p)throw bad_pattern("Bad sub-expression");
+#endif
+   BOOST_REGEX_NOEH_ASSERT(0 == *p)
    return result;
 }
 
@@ -807,7 +824,10 @@ sub_match<iterator>::operator int()const
 {
    iterator i = first;
    iterator j = second;
+#ifndef BOOST_NO_EXCEPTIONS
    if(i == j)throw bad_pattern("Bad sub-expression");
+#endif
+   BOOST_REGEX_NOEH_ASSERT(i != j)
    int neg = 1;
    if((i != j) && (*i == '-'))
    {
@@ -815,7 +835,10 @@ sub_match<iterator>::operator int()const
       ++i;
    }
    neg *= re_detail::do_toi(i, j, *i);
+#ifndef BOOST_NO_EXCEPTIONS
    if(i != j)throw bad_pattern("Bad sub-expression");
+#endif
+   BOOST_REGEX_NOEH_ASSERT(i == j)
    return neg;
 }
 template <class iterator>
@@ -823,21 +846,25 @@ sub_match<iterator>::operator unsigned int()const
 {
    iterator i = first;
    iterator j = second;
+#ifndef BOOST_NO_EXCEPTIONS
    if(i == j)
       throw bad_pattern("Bad sub-expression");
+#endif
+   BOOST_REGEX_NOEH_ASSERT(i != j)
    return re_detail::do_toi(i, j, *first);
 }
 #endif
 
 namespace re_detail{
 
-template <class iterator, class Allocator BOOST_RE_DEF_ALLOC_PARAM(typename def_alloc_param_traits<iterator>::type) >
+template <class iterator, class Allocator = BOOST_DEFAULT_ALLOCATOR(typename def_alloc_param_traits<iterator>::type) >
 class match_results_base
 {
 public:
    typedef Allocator                                                 alloc_type;
-   typedef typename REBIND_TYPE(iterator, Allocator)::size_type      size_type;
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+   typedef typename boost::detail::rebind_allocator<iterator, Allocator>::type  iterator_alloc;
+   typedef typename iterator_alloc::size_type                        size_type;
+#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ITERATOR_TRAITS)
    typedef typename std::iterator_traits<iterator>::difference_type  difference_type;
    typedef typename std::iterator_traits<iterator>::value_type       char_type;
 #else
@@ -848,16 +875,17 @@ public:
    typedef iterator                                                  iterator_type;
 
 protected:
-   typedef BOOST_RE_MAYBE_TYPENAME REBIND_TYPE(char, Allocator) c_alloc;
+   typedef typename boost::detail::rebind_allocator<char, Allocator>::type c_alloc;
    
    struct c_reference : public c_alloc
    {
-      unsigned int cmatches;
+      std::size_t cmatches;
       unsigned count;
       sub_match<iterator> head, tail, null;
       unsigned int lines;
       iterator line_pos, base;
-      c_reference(const Allocator& a) : c_alloc(a) {  }
+      c_reference(const Allocator& a)
+         : c_alloc(a), cmatches(0), count(0), lines(0) {  }
 
       bool operator==(const c_reference& that)const
       {
@@ -874,11 +902,11 @@ protected:
 
    c_reference* ref;
 
-   void BOOST_RE_CALL cow();
+   void BOOST_REGEX_CALL cow();
 
    // protected contructor for derived class...
    match_results_base(bool){}
-   void BOOST_RE_CALL free();
+   void BOOST_REGEX_CALL m_free();
 
 public:
 
@@ -890,36 +918,35 @@ public:
       ++(ref->count);
    }
 
-   match_results_base& BOOST_RE_CALL operator=(const match_results_base& m);
+   match_results_base& BOOST_REGEX_CALL operator=(const match_results_base& m);
 
    ~match_results_base()
    {
-      free();
+      m_free();
    }
 
-   size_type BOOST_RE_CALL size()const
+   size_type BOOST_REGEX_CALL size()const
    {
       //return (*this)[0].matched ? ref->cmatches : 0;
       return ref->cmatches;
    }
 
-   const sub_match<iterator>& BOOST_RE_CALL operator[](int n) const
+   const sub_match<iterator>& BOOST_REGEX_CALL operator[](int n) const
    {
       if((n >= 0) && ((unsigned int)n < ref->cmatches))
          return *(sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>)*n);
       return (n == -1) ? ref->head : (n == -2) ? ref->tail : ref->null;
    }
 
-   Allocator BOOST_RE_CALL allocator()const;
+   Allocator BOOST_REGEX_CALL allocator()const;
 
-   difference_type BOOST_RE_CALL length(unsigned int sub = 0)const
+   difference_type BOOST_REGEX_CALL length(unsigned int sub = 0)const
    {
       jm_assert(ref->cmatches);
       const sub_match<iterator>& m = (*this)[sub];
       if(m.matched == false)
          return 0;
-      difference_type n;
-      BOOST_RE_DISTANCE((iterator)m.first, (iterator)m.second, n);
+      difference_type n = boost::re_detail::distance((iterator)m.first, (iterator)m.second);
       return n;
    }
 
@@ -928,23 +955,22 @@ public:
       return static_cast<std::basic_string<char_type> >((*this)[i]);
    }
 
-   unsigned int BOOST_RE_CALL line()const
+   unsigned int BOOST_REGEX_CALL line()const
    {
       return ref->lines;
    }
 
-   difference_type BOOST_RE_CALL position(unsigned int sub = 0)const
+   difference_type BOOST_REGEX_CALL position(unsigned int sub = 0)const
    {
       jm_assert(ref->cmatches);
       const sub_match<iterator>& s = (*this)[sub];
       if(s.matched == false)
          return -1;
-      difference_type n;
-      BOOST_RE_DISTANCE((iterator)ref->base, (iterator)s.first, n);
+      difference_type n = boost::re_detail::distance((iterator)(ref->base), (iterator)(s.first));
       return n;
    }
 
-   iterator BOOST_RE_CALL line_start()const
+   iterator BOOST_REGEX_CALL line_start()const
    {
       return ref->line_pos;
    }
@@ -962,15 +988,15 @@ public:
 
    friend class match_results<iterator, Allocator>;
 
-   void BOOST_RE_CALL set_size(size_type n);
-   void BOOST_RE_CALL set_size(size_type n, iterator i, iterator j);
-   void BOOST_RE_CALL maybe_assign(const match_results_base& m);
-   void BOOST_RE_CALL init_fail(iterator i, iterator j);
+   void BOOST_REGEX_CALL set_size(size_type n);
+   void BOOST_REGEX_CALL set_size(size_type n, iterator i, iterator j);
+   void BOOST_REGEX_CALL maybe_assign(const match_results_base& m);
+   void BOOST_REGEX_CALL init_fail(iterator i, iterator j);
 
-   void BOOST_RE_CALL set_first(iterator i);
-   void BOOST_RE_CALL set_first(iterator i, size_t pos);
+   void BOOST_REGEX_CALL set_first(iterator i);
+   void BOOST_REGEX_CALL set_first(iterator i, std::size_t pos);
 
-   void BOOST_RE_CALL set_second(iterator i)
+   void BOOST_REGEX_CALL set_second(iterator i)
    {
       cow();
       ((sub_match<iterator>*)(ref+1))->second = i;
@@ -979,11 +1005,11 @@ public:
       ref->tail.matched = (ref->tail.first == ref->tail.second) ? false : true;
    }
 
-   void BOOST_RE_CALL set_second(iterator i, size_t pos)
+   void BOOST_REGEX_CALL set_second(iterator i, std::size_t pos, bool m = true)
    {
       cow();
       ((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->second = i;
-      ((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->matched = true;
+      ((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->matched = m;
       if(pos == 0)
       {
          ref->tail.first = i;
@@ -991,20 +1017,20 @@ public:
       }
    }
 
-   void BOOST_RE_CALL set_line(unsigned int i, iterator pos)
+   void BOOST_REGEX_CALL set_line(unsigned int i, iterator pos)
    {
       ref->lines = i;
       ref->line_pos = pos;
    }
 
-   void BOOST_RE_CALL set_base(iterator pos)
+   void BOOST_REGEX_CALL set_base(iterator pos)
    {
       ref->base = pos;
    }
 };
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::set_first(iterator i)
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_first(iterator i)
 {
    cow();
    ref->head.second = i;
@@ -1024,7 +1050,7 @@ void BOOST_RE_CALL match_results_base<iterator, Allocator>::set_first(iterator i
 }
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::set_first(iterator i, size_t pos)
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_first(iterator i, std::size_t pos)
 {
    cow();
    ((sub_match<iterator>*)((char*)ref + sizeof(c_reference) + sizeof(sub_match<iterator>) * pos))->first = i;
@@ -1052,41 +1078,48 @@ template <class iterator, class Allocator>
 match_results_base<iterator, Allocator>::match_results_base(const Allocator& a)
 {
    ref = (c_reference*)c_alloc(a).allocate(sizeof(sub_match<iterator>) + sizeof(c_reference));
+   BOOST_REGEX_NOEH_ASSERT(ref)
+#ifndef BOOST_NO_EXCEPTIONS
    try
    {
+#endif
       new (ref) c_reference(a);
       ref->cmatches = 1;
       ref->count = 1;
       // construct the sub_match<iterator>:
+#ifndef BOOST_NO_EXCEPTIONS
       try
       {
+#endif
          new ((sub_match<iterator>*)(ref+1)) sub_match<iterator>();
+#ifndef BOOST_NO_EXCEPTIONS
       }
       catch(...)
-      { 
-         jm_destroy(ref); 
-         throw; 
+      {
+         ::boost::re_detail::pointer_destroy(ref);
+         throw;
       }
    }
    catch(...)
-   { 
-      c_alloc(a).deallocate((char*)(void*)ref, sizeof(sub_match<iterator>) + sizeof(c_reference)); 
-      throw; 
+   {
+      c_alloc(a).deallocate((char*)(void*)ref, sizeof(sub_match<iterator>) + sizeof(c_reference));
+      throw;
    }
+#endif
 }
 
 template <class iterator, class Allocator>
-Allocator BOOST_RE_CALL match_results_base<iterator, Allocator>::allocator()const
+Allocator BOOST_REGEX_CALL match_results_base<iterator, Allocator>::allocator()const
 {
   return *((c_alloc*)ref);
 }
 
 template <class iterator, class Allocator>
-inline match_results_base<iterator, Allocator>& BOOST_RE_CALL match_results_base<iterator, Allocator>::operator=(const match_results_base<iterator, Allocator>& m)
+inline match_results_base<iterator, Allocator>& BOOST_REGEX_CALL match_results_base<iterator, Allocator>::operator=(const match_results_base<iterator, Allocator>& m)
 {
    if(ref != m.ref)
    {
-      free();
+      m_free();
       ref = m.ref;
       ++(ref->count);
    }
@@ -1095,7 +1128,7 @@ inline match_results_base<iterator, Allocator>& BOOST_RE_CALL match_results_base
 
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::free()
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::m_free()
 {
    if(--(ref->count) == 0)
    {
@@ -1105,10 +1138,10 @@ void BOOST_RE_CALL match_results_base<iterator, Allocator>::free()
       p2 = p1 + ref->cmatches;
       while(p1 != p2)
       {
-         jm_destroy(p1);
+         ::boost::re_detail::pointer_destroy(p1);
          ++p1;
       }
-      jm_destroy(ref);
+      ::boost::re_detail::pointer_destroy(ref);
       a.deallocate((char*)(void*)ref, sizeof(sub_match<iterator>) * ref->cmatches + sizeof(c_reference));
    }
 }
@@ -1132,88 +1165,106 @@ bool match_results_base<iterator, Allocator>::operator==(const match_results_bas
 }
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::set_size(size_type n)
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_size(size_type n)
 {
    if(ref->cmatches != n)
    {
       c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * n + sizeof(c_reference));
+      BOOST_REGEX_NOEH_ASSERT(newref)
+#ifndef BOOST_NO_EXCEPTIONS
       try
       {
+#endif
          new (newref) c_reference(*ref);
          newref->count = 1;
          newref->cmatches = n;
          sub_match<iterator>* p1, *p2;
          p1 = (sub_match<iterator>*)(newref+1);
          p2 = p1 + newref->cmatches;
+#ifndef BOOST_NO_EXCEPTIONS
          try
          {
+#endif
             while(p1 != p2)
             {
                new (p1) sub_match<iterator>();
                ++p1;
             }
-            free();
+            m_free();
+#ifndef BOOST_NO_EXCEPTIONS
          }
          catch(...)
-         { 
+         {
             p2 = (sub_match<iterator>*)(newref+1);
             while(p2 != p1)
             {
-               jm_destroy(p2);
+               ::boost::re_detail::pointer_destroy(p2);
                ++p2;
             }
-            jm_destroy(ref);
-            throw; 
+            ::boost::re_detail::pointer_destroy(ref);
+            throw;
          }
+#endif
          ref = newref;
+#ifndef BOOST_NO_EXCEPTIONS
       }
       catch(...)
-      { 
-         ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * n + sizeof(c_reference)); 
-         throw; 
+      {
+         ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * n + sizeof(c_reference));
+         throw;
       }
+#endif
    }
 }
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::set_size(size_type n, iterator i, iterator j)
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::set_size(size_type n, iterator i, iterator j)
 {
    if(ref->cmatches != n)
    {
-      c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * n + sizeof(c_reference));;
+      c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * n + sizeof(c_reference));
+      BOOST_REGEX_NOEH_ASSERT(newref)
+#ifndef BOOST_NO_EXCEPTIONS
       try{
+#endif
          new (newref) c_reference(*ref);
          newref->count = 1;
          newref->cmatches = n;
          sub_match<iterator>* p1 = (sub_match<iterator>*)(newref+1);
          sub_match<iterator>* p2 = p1 + newref->cmatches;
+#ifndef BOOST_NO_EXCEPTIONS
          try
          {
+#endif
             while(p1 != p2)
             {
                new (p1) sub_match<iterator>(j);
                ++p1;
             }
-            free();
+            m_free();
+#ifndef BOOST_NO_EXCEPTIONS
          }
          catch(...)
          { 
             p2 = (sub_match<iterator>*)(newref+1);
             while(p2 != p1)
             {
-               jm_destroy(p2);
+               ::boost::re_detail::pointer_destroy(p2);
                ++p2;
             }
-            jm_destroy(ref);
+            ::boost::re_detail::pointer_destroy(ref);
             throw; 
          }
+#endif
          ref = newref;
+#ifndef BOOST_NO_EXCEPTIONS
       }
       catch(...)
       { 
          ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * n + sizeof(c_reference)); 
          throw; 
       }
+#endif
    }
    else
    {
@@ -1238,34 +1289,34 @@ void BOOST_RE_CALL match_results_base<iterator, Allocator>::set_size(size_type n
 }
 
 template <class iterator, class Allocator>
-inline void BOOST_RE_CALL match_results_base<iterator, Allocator>::init_fail(iterator i, iterator j)
+inline void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::init_fail(iterator i, iterator j)
 {
    set_size(ref->cmatches, i, j);
 }
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::maybe_assign(const match_results_base<iterator, Allocator>& m)
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::maybe_assign(const match_results_base<iterator, Allocator>& m)
 {
    sub_match<iterator>* p1, *p2;
    p1 = (sub_match<iterator>*)(ref+1);
    p2 = (sub_match<iterator>*)(m.ref+1);
    iterator base = (*this)[-1].first;
-   unsigned int len1 = 0;
-   unsigned int len2 = 0;
-   unsigned int base1 = 0;
-   unsigned int base2 = 0;
-   unsigned int i;
+   std::size_t len1 = 0;
+   std::size_t len2 = 0;
+   std::size_t base1 = 0;
+   std::size_t base2 = 0;
+   std::size_t i;
    for(i = 0; i < ref->cmatches; ++i)
    {
       //
       // leftmost takes priority over longest:
-      BOOST_RE_DISTANCE(base, p1->first, base1);
-      BOOST_RE_DISTANCE(base, p2->first, base2);
+      base1 = boost::re_detail::distance(base, p1->first);
+      base2 = boost::re_detail::distance(base, p2->first);
       if(base1 < base2) return;
       if(base2 < base1) break;
 
-      BOOST_RE_DISTANCE(p1->first, p1->second, len1);
-      BOOST_RE_DISTANCE(p2->first, p2->second, len2);
+      len1 = boost::re_detail::distance(p1->first, p1->second);
+      len2 = boost::re_detail::distance(p2->first, p2->second);
       if((len1 != len2) || ((p1->matched == false) && (p2->matched == true)))
          break;
       if((p1->matched == true) && (p2->matched == false))
@@ -1282,44 +1333,53 @@ void BOOST_RE_CALL match_results_base<iterator, Allocator>::maybe_assign(const m
 }
 
 template <class iterator, class Allocator>
-void BOOST_RE_CALL match_results_base<iterator, Allocator>::cow()
+void BOOST_REGEX_CALL match_results_base<iterator, Allocator>::cow()
 {
    if(ref->count > 1)
    {
       c_reference* newref = (c_reference*)ref->allocate(sizeof(sub_match<iterator>) * ref->cmatches + sizeof(c_reference));
+      BOOST_REGEX_NOEH_ASSERT(newref)
+#ifndef BOOST_NO_EXCEPTIONS
       try{
+#endif
          new (newref) c_reference(*ref);
          newref->count = 1;
          sub_match<iterator>* p1 = (sub_match<iterator>*)(newref+1);
          sub_match<iterator>* p2 = p1 + newref->cmatches;
          sub_match<iterator>* p3 = (sub_match<iterator>*)(ref+1);
+#ifndef BOOST_NO_EXCEPTIONS
          try{
+#endif
             while(p1 != p2)
             {
                new (p1) sub_match<iterator>(*p3);
                ++p1;
                ++p3;
             }
+#ifndef BOOST_NO_EXCEPTIONS
          }
          catch(...)
          { 
             p2 = (sub_match<iterator>*)(newref+1);
             while(p2 != p1)
             {
-               jm_destroy(p2);
+               ::boost::re_detail::pointer_destroy(p2);
                ++p2;
             }
-            jm_destroy(ref);
+            ::boost::re_detail::pointer_destroy(ref);
             throw; 
          }
+#endif
       --(ref->count);
       ref = newref;
+#ifndef BOOST_NO_EXCEPTIONS
       }
       catch(...)
       { 
          ref->deallocate((char*)(void*)newref, sizeof(sub_match<iterator>) * ref->cmatches + sizeof(c_reference)); 
          throw; 
       }
+#endif
    }
 }
 
@@ -1407,29 +1467,35 @@ match_results<iterator, Allocator>::match_results(const match_results<iterator,
       reinterpret_cast<typename re_detail::match_results_base<iterator, Allocator>::c_reference *>
          (m.ref->allocate(sizeof(sub_match<iterator>) * m.ref->cmatches +
                           sizeof(typename re_detail::match_results_base<iterator, Allocator>::c_reference)));
+   BOOST_REGEX_NOEH_ASSERT(this->ref)                       
+#ifndef BOOST_NO_EXCEPTIONS
    try{
+#endif
       new (this->ref) typename re_detail::match_results_base<iterator, Allocator>::c_reference(*m.ref);
       this->ref->count = 1;
       sub_match<iterator>* p1 = (sub_match<iterator>*)(this->ref+1);
       sub_match<iterator>* p2 = p1 + this->ref->cmatches;
       sub_match<iterator>* p3 = (sub_match<iterator>*)(m.ref+1);
+#ifndef BOOST_NO_EXCEPTIONS
       try{
+#endif
          while(p1 != p2)
          {
             new (p1) sub_match<iterator>(*p3);
             ++p1;
             ++p3;
          }
+#ifndef BOOST_NO_EXCEPTIONS
       }
       catch(...)
       { 
          p2 = (sub_match<iterator>*)(this->ref+1);
          while(p2 != p1)
          {
-            re_detail::jm_destroy(p2);
+            re_detail::pointer_destroy(p2);
             ++p2;
          }
-         re_detail::jm_destroy(this->ref);
+         re_detail::pointer_destroy(this->ref);
          throw; 
       }
    }
@@ -1438,6 +1504,7 @@ match_results<iterator, Allocator>::match_results(const match_results<iterator,
       m.ref->deallocate((char*)(void*)this->ref, sizeof(sub_match<iterator>) * m.ref->cmatches + sizeof(typename re_detail::match_results_base<iterator, Allocator>::c_reference));
       throw; 
    }
+#endif
 }
 
 template <class iterator, class Allocator>
@@ -1450,39 +1517,65 @@ match_results<iterator, Allocator>& match_results<iterator, Allocator>::operator
 
 namespace re_detail{
 template <class iterator, class charT, class traits_type, class Allocator>
-iterator BOOST_RE_CALL re_is_set_member(iterator next, 
+iterator BOOST_REGEX_CALL re_is_set_member(iterator next, 
                           iterator last, 
-                          re_set_long* set_, 
+                          const re_set_long* set_, 
                           const reg_expression<charT, traits_type, Allocator>& e);
 } // namepsace re_detail
 
 #ifdef __BORLANDC__
- #if __BORLANDC__ > 0x520
   #pragma option pop
- #endif
 #endif
 
 } // namespace boost
 
-#include <boost/re_detail/regex_compile.hpp>
+#include <boost/regex/detail/regex_compile.hpp>
 
-namespace boost{
+//
+// template instances:
+//
+#define BOOST_REGEX_CHAR_T char
+#ifdef BOOST_REGEX_NARROW_INSTANTIATE
+#  define BOOST_REGEX_INSTANTIATE
+#endif
+#include <boost/regex/detail/instances.hpp>
+#undef BOOST_REGEX_CHAR_T
+#ifdef BOOST_REGEX_INSTANTIATE
+#  undef BOOST_REGEX_INSTANTIATE
+#endif
 
-typedef reg_expression<char, regex_traits<char>, BOOST_RE_DEF_ALLOC(char)> regex;
-#ifndef BOOST_RE_NO_WCSTRING
-typedef reg_expression<wchar_t, regex_traits<wchar_t>, BOOST_RE_DEF_ALLOC(wchar_t)> wregex;
+#ifndef BOOST_NO_WREGEX
+#define BOOST_REGEX_CHAR_T wchar_t
+#ifdef BOOST_REGEX_WIDE_INSTANTIATE
+#  define BOOST_REGEX_INSTANTIATE
+#endif
+#include <boost/regex/detail/instances.hpp>
+#undef BOOST_REGEX_CHAR_T
+#ifdef BOOST_REGEX_INSTANTIATE
+#  undef BOOST_REGEX_INSTANTIATE
+#endif
+#endif
+
+
+namespace boost{
+#ifdef BOOST_REGEX_NO_FWD
+typedef reg_expression<char, regex_traits<char>, BOOST_DEFAULT_ALLOCATOR(char)> regex;
+#ifndef BOOST_NO_WREGEX
+typedef reg_expression<wchar_t, regex_traits<wchar_t>, BOOST_DEFAULT_ALLOCATOR(wchar_t)> wregex;
+#endif
 #endif
 
 typedef match_results<const char*> cmatch;
-#ifndef BOOST_RE_NO_WCSTRING
+typedef match_results<std::string::const_iterator> smatch;
+#ifndef BOOST_NO_WREGEX
 typedef match_results<const wchar_t*> wcmatch;
+typedef match_results<std::wstring::const_iterator> wsmatch;
 #endif
 
 } // namespace boost
-
-#include <boost/re_detail/regex_match.hpp>
-#include <boost/re_detail/regex_format.hpp>
-#include <boost/re_detail/regex_split.hpp>
+#include <boost/regex/detail/regex_match.hpp>
+#include <boost/regex/detail/regex_format.hpp>
+#include <boost/regex/detail/regex_split.hpp>
 
 
 #endif  // __cplusplus
@@ -1510,6 +1603,8 @@ typedef match_results<const wchar_t*> wcmatch;
 
 
 
+
+