os/ossrv/ossrv_pub/boost_apis/boost/regex/icu.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/regex/icu.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1017 @@
     1.4 +/*
     1.5 + *
     1.6 + * Copyright (c) 2004
     1.7 + * John Maddock
     1.8 + *
     1.9 + * Use, modification and distribution are subject to the 
    1.10 + * Boost Software License, Version 1.0. (See accompanying file 
    1.11 + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    1.12 + *
    1.13 + */
    1.14 +
    1.15 + /*
    1.16 +  *   LOCATION:    see http://www.boost.org for most recent version.
    1.17 +  *   FILE         icu.hpp
    1.18 +  *   VERSION      see <boost/version.hpp>
    1.19 +  *   DESCRIPTION: Unicode regular expressions on top of the ICU Library.
    1.20 +  */
    1.21 +
    1.22 +#ifndef BOOST_REGEX_ICU_HPP
    1.23 +#define BOOST_REGEX_ICU_HPP
    1.24 +
    1.25 +#include <unicode/utypes.h>
    1.26 +#include <unicode/uchar.h>
    1.27 +#include <unicode/coll.h>
    1.28 +#include <boost/regex.hpp>
    1.29 +#include <boost/regex/pending/unicode_iterator.hpp>
    1.30 +#include <boost/mpl/int_fwd.hpp>
    1.31 +#include <bitset>
    1.32 +
    1.33 +
    1.34 +namespace boost{
    1.35 +
    1.36 +namespace re_detail{
    1.37 +
    1.38 +// 
    1.39 +// Implementation details:
    1.40 +//
    1.41 +class BOOST_REGEX_DECL icu_regex_traits_implementation
    1.42 +{
    1.43 +   typedef UChar32                      char_type;
    1.44 +   typedef std::size_t                  size_type;
    1.45 +   typedef std::vector<char_type>       string_type;
    1.46 +   typedef U_NAMESPACE_QUALIFIER Locale locale_type;
    1.47 +   typedef boost::uint_least32_t        char_class_type;
    1.48 +public:
    1.49 +   icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& l)
    1.50 +      : m_locale(l)
    1.51 +   {
    1.52 +      UErrorCode success = U_ZERO_ERROR;
    1.53 +      m_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success));
    1.54 +      if(U_SUCCESS(success) == 0)
    1.55 +         init_error();
    1.56 +      m_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::IDENTICAL);
    1.57 +      success = U_ZERO_ERROR;
    1.58 +      m_primary_collator.reset(U_NAMESPACE_QUALIFIER Collator::createInstance(l, success));
    1.59 +      if(U_SUCCESS(success) == 0)
    1.60 +         init_error();
    1.61 +      m_primary_collator->setStrength(U_NAMESPACE_QUALIFIER Collator::PRIMARY);
    1.62 +   }
    1.63 +   U_NAMESPACE_QUALIFIER Locale getloc()const
    1.64 +   {
    1.65 +      return m_locale;
    1.66 +   }
    1.67 +   string_type do_transform(const char_type* p1, const char_type* p2, const U_NAMESPACE_QUALIFIER Collator* pcoll) const;
    1.68 +   string_type transform(const char_type* p1, const char_type* p2) const
    1.69 +   {
    1.70 +      return do_transform(p1, p2, m_collator.get());
    1.71 +   }
    1.72 +   string_type transform_primary(const char_type* p1, const char_type* p2) const
    1.73 +   {
    1.74 +      return do_transform(p1, p2, m_primary_collator.get());
    1.75 +   }
    1.76 +private:
    1.77 +   void init_error()
    1.78 +   {
    1.79 +      std::runtime_error e("Could not initialize ICU resources");
    1.80 +      boost::throw_exception(e);
    1.81 +   }
    1.82 +   U_NAMESPACE_QUALIFIER Locale m_locale;                                  // The ICU locale that we're using
    1.83 +   boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_collator;          // The full collation object
    1.84 +   boost::scoped_ptr< U_NAMESPACE_QUALIFIER Collator> m_primary_collator;  // The primary collation object
    1.85 +};
    1.86 +
    1.87 +inline boost::shared_ptr<icu_regex_traits_implementation> get_icu_regex_traits_implementation(const U_NAMESPACE_QUALIFIER Locale& loc)
    1.88 +{
    1.89 +   return boost::shared_ptr<icu_regex_traits_implementation>(new icu_regex_traits_implementation(loc));
    1.90 +}
    1.91 +
    1.92 +}
    1.93 +
    1.94 +class BOOST_REGEX_DECL icu_regex_traits
    1.95 +{
    1.96 +public:
    1.97 +   typedef UChar32                      char_type;
    1.98 +   typedef std::size_t                  size_type;
    1.99 +   typedef std::vector<char_type>       string_type;
   1.100 +   typedef U_NAMESPACE_QUALIFIER Locale locale_type;
   1.101 +#ifdef BOOST_NO_INT64_T
   1.102 +   typedef std::bitset<64>              char_class_type;
   1.103 +#else
   1.104 +   typedef boost::uint64_t              char_class_type;
   1.105 +#endif
   1.106 +
   1.107 +   struct boost_extensions_tag{};
   1.108 +
   1.109 +   icu_regex_traits()
   1.110 +      : m_pimpl(re_detail::get_icu_regex_traits_implementation(U_NAMESPACE_QUALIFIER Locale()))
   1.111 +   {
   1.112 +   }
   1.113 +   static size_type length(const char_type* p);
   1.114 +
   1.115 +   ::boost::regex_constants::syntax_type syntax_type(char_type c)const
   1.116 +   {
   1.117 +      return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char;
   1.118 +   }
   1.119 +   ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c) const
   1.120 +   {
   1.121 +      return ((c < 0x7f) && (c > 0)) ? re_detail::get_default_escape_syntax_type(static_cast<char>(c)) : regex_constants::syntax_char;
   1.122 +   }
   1.123 +   char_type translate(char_type c) const
   1.124 +   {
   1.125 +      return c;
   1.126 +   }
   1.127 +   char_type translate_nocase(char_type c) const
   1.128 +   {
   1.129 +      return ::u_tolower(c);
   1.130 +   }
   1.131 +   char_type translate(char_type c, bool icase) const
   1.132 +   {
   1.133 +      return icase ? translate_nocase(c) : translate(c);
   1.134 +   }
   1.135 +   char_type tolower(char_type c) const
   1.136 +   {
   1.137 +      return ::u_tolower(c);
   1.138 +   }
   1.139 +   char_type toupper(char_type c) const
   1.140 +   {
   1.141 +      return ::u_toupper(c);
   1.142 +   }
   1.143 +   string_type transform(const char_type* p1, const char_type* p2) const
   1.144 +   {
   1.145 +      return m_pimpl->transform(p1, p2);
   1.146 +   }
   1.147 +   string_type transform_primary(const char_type* p1, const char_type* p2) const
   1.148 +   {
   1.149 +      return m_pimpl->transform_primary(p1, p2);
   1.150 +   }
   1.151 +   char_class_type lookup_classname(const char_type* p1, const char_type* p2) const;
   1.152 +   string_type lookup_collatename(const char_type* p1, const char_type* p2) const;
   1.153 +   bool isctype(char_type c, char_class_type f) const;
   1.154 +   int toi(const char_type*& p1, const char_type* p2, int radix)const
   1.155 +   {
   1.156 +      return re_detail::global_toi(p1, p2, radix, *this);
   1.157 +   }
   1.158 +   int value(char_type c, int radix)const
   1.159 +   {
   1.160 +      return u_digit(c, static_cast< ::int8_t>(radix));
   1.161 +   }
   1.162 +   locale_type imbue(locale_type l)
   1.163 +   {
   1.164 +      locale_type result(m_pimpl->getloc());
   1.165 +      m_pimpl = re_detail::get_icu_regex_traits_implementation(l);
   1.166 +      return result;
   1.167 +   }
   1.168 +   locale_type getloc()const
   1.169 +   {
   1.170 +      return locale_type();
   1.171 +   }
   1.172 +   std::string error_string(::boost::regex_constants::error_type n) const
   1.173 +   {
   1.174 +      return re_detail::get_default_error_string(n);
   1.175 +   }
   1.176 +private:
   1.177 +   icu_regex_traits(const icu_regex_traits&);
   1.178 +   icu_regex_traits& operator=(const icu_regex_traits&);
   1.179 +
   1.180 +   //
   1.181 +   // define the bitmasks offsets we need for additional character properties:
   1.182 +   //
   1.183 +   enum{
   1.184 +      offset_blank = U_CHAR_CATEGORY_COUNT,
   1.185 +      offset_space = U_CHAR_CATEGORY_COUNT+1,
   1.186 +      offset_xdigit = U_CHAR_CATEGORY_COUNT+2,
   1.187 +      offset_underscore = U_CHAR_CATEGORY_COUNT+3,
   1.188 +      offset_unicode = U_CHAR_CATEGORY_COUNT+4,
   1.189 +      offset_any = U_CHAR_CATEGORY_COUNT+5,
   1.190 +      offset_ascii = U_CHAR_CATEGORY_COUNT+6
   1.191 +   };
   1.192 +
   1.193 +   //
   1.194 +   // and now the masks:
   1.195 +   //
   1.196 +   static const char_class_type mask_blank;
   1.197 +   static const char_class_type mask_space;
   1.198 +   static const char_class_type mask_xdigit;
   1.199 +   static const char_class_type mask_underscore;
   1.200 +   static const char_class_type mask_unicode;
   1.201 +   static const char_class_type mask_any;
   1.202 +   static const char_class_type mask_ascii;
   1.203 +
   1.204 +   static char_class_type lookup_icu_mask(const ::UChar32* p1, const ::UChar32* p2);
   1.205 +
   1.206 +   boost::shared_ptr< ::boost::re_detail::icu_regex_traits_implementation> m_pimpl;
   1.207 +};
   1.208 +
   1.209 +} // namespace boost
   1.210 +
   1.211 +//
   1.212 +// template instances:
   1.213 +//
   1.214 +#define BOOST_REGEX_CHAR_T UChar32
   1.215 +#undef BOOST_REGEX_TRAITS_T
   1.216 +#define BOOST_REGEX_TRAITS_T , icu_regex_traits
   1.217 +#define BOOST_REGEX_ICU_INSTANCES
   1.218 +#ifdef BOOST_REGEX_ICU_INSTANTIATE
   1.219 +#  define BOOST_REGEX_INSTANTIATE
   1.220 +#endif
   1.221 +#include <boost/regex/v4/instances.hpp>
   1.222 +#undef BOOST_REGEX_CHAR_T
   1.223 +#undef BOOST_REGEX_TRAITS_T
   1.224 +#undef BOOST_REGEX_ICU_INSTANCES
   1.225 +#ifdef BOOST_REGEX_INSTANTIATE
   1.226 +#  undef BOOST_REGEX_INSTANTIATE
   1.227 +#endif
   1.228 +
   1.229 +namespace boost{
   1.230 +
   1.231 +// types:
   1.232 +typedef basic_regex< ::UChar32, icu_regex_traits> u32regex;
   1.233 +typedef match_results<const ::UChar32*> u32match;
   1.234 +typedef match_results<const ::UChar*> u16match;
   1.235 +
   1.236 +//
   1.237 +// Construction of 32-bit regex types from UTF-8 and UTF-16 primitives:
   1.238 +//
   1.239 +namespace re_detail{
   1.240 +
   1.241 +#if !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__)
   1.242 +template <class InputIterator>
   1.243 +inline u32regex do_make_u32regex(InputIterator i, 
   1.244 +                              InputIterator j, 
   1.245 +                              boost::regex_constants::syntax_option_type opt, 
   1.246 +                              const boost::mpl::int_<1>*)
   1.247 +{
   1.248 +   typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type;
   1.249 +   return u32regex(conv_type(i), conv_type(j), opt);
   1.250 +}
   1.251 +
   1.252 +template <class InputIterator>
   1.253 +inline u32regex do_make_u32regex(InputIterator i, 
   1.254 +                              InputIterator j, 
   1.255 +                              boost::regex_constants::syntax_option_type opt, 
   1.256 +                              const boost::mpl::int_<2>*)
   1.257 +{
   1.258 +   typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type;
   1.259 +   return u32regex(conv_type(i), conv_type(j), opt);
   1.260 +}
   1.261 +
   1.262 +template <class InputIterator>
   1.263 +inline u32regex do_make_u32regex(InputIterator i, 
   1.264 +                              InputIterator j, 
   1.265 +                              boost::regex_constants::syntax_option_type opt, 
   1.266 +                              const boost::mpl::int_<4>*)
   1.267 +{
   1.268 +   return u32regex(i, j, opt);
   1.269 +}
   1.270 +#else
   1.271 +template <class InputIterator>
   1.272 +inline u32regex do_make_u32regex(InputIterator i, 
   1.273 +                              InputIterator j, 
   1.274 +                              boost::regex_constants::syntax_option_type opt, 
   1.275 +                              const boost::mpl::int_<1>*)
   1.276 +{
   1.277 +   typedef boost::u8_to_u32_iterator<InputIterator, UChar32> conv_type;
   1.278 +   typedef std::vector<UChar32> vector_type;
   1.279 +   vector_type v;
   1.280 +   conv_type a(i), b(j);
   1.281 +   while(a != b)
   1.282 +   {
   1.283 +      v.push_back(*a);
   1.284 +      ++a;
   1.285 +   }
   1.286 +   if(v.size())
   1.287 +      return u32regex(&*v.begin(), v.size(), opt);
   1.288 +   return u32regex(static_cast<UChar32 const*>(0), static_cast<u32regex::size_type>(0), opt);
   1.289 +}
   1.290 +
   1.291 +template <class InputIterator>
   1.292 +inline u32regex do_make_u32regex(InputIterator i, 
   1.293 +                              InputIterator j, 
   1.294 +                              boost::regex_constants::syntax_option_type opt, 
   1.295 +                              const boost::mpl::int_<2>*)
   1.296 +{
   1.297 +   typedef boost::u16_to_u32_iterator<InputIterator, UChar32> conv_type;
   1.298 +   typedef std::vector<UChar32> vector_type;
   1.299 +   vector_type v;
   1.300 +   conv_type a(i), b(j);
   1.301 +   while(a != b)
   1.302 +   {
   1.303 +      v.push_back(*a);
   1.304 +      ++a;
   1.305 +   }
   1.306 +   if(v.size())
   1.307 +      return u32regex(&*v.begin(), v.size(), opt);
   1.308 +   return u32regex(static_cast<UChar32 const*>(0), static_cast<u32regex::size_type>(0), opt);
   1.309 +}
   1.310 +
   1.311 +template <class InputIterator>
   1.312 +inline u32regex do_make_u32regex(InputIterator i, 
   1.313 +                              InputIterator j, 
   1.314 +                              boost::regex_constants::syntax_option_type opt, 
   1.315 +                              const boost::mpl::int_<4>*)
   1.316 +{
   1.317 +   typedef std::vector<UCHAR32> vector_type;
   1.318 +   vector_type v;
   1.319 +   while(i != j)
   1.320 +   {
   1.321 +      v.push_back((UCHAR32)(*i));
   1.322 +      ++a;
   1.323 +   }
   1.324 +   if(v.size())
   1.325 +      return u32regex(&*v.begin(), v.size(), opt);
   1.326 +   return u32regex(static_cast<UChar32 const*>(0), static_cast<u32regex::size_type>(0), opt);
   1.327 +}
   1.328 +#endif
   1.329 +}
   1.330 +
   1.331 +//
   1.332 +// Construction from an iterator pair:
   1.333 +//
   1.334 +template <class InputIterator>
   1.335 +inline u32regex make_u32regex(InputIterator i, 
   1.336 +                              InputIterator j, 
   1.337 +                              boost::regex_constants::syntax_option_type opt)
   1.338 +{
   1.339 +   return re_detail::do_make_u32regex(i, j, opt, static_cast<boost::mpl::int_<sizeof(*i)> const*>(0));
   1.340 +}
   1.341 +//
   1.342 +// construction from UTF-8 nul-terminated strings:
   1.343 +//
   1.344 +inline u32regex make_u32regex(const char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl)
   1.345 +{
   1.346 +   return re_detail::do_make_u32regex(p, p + std::strlen(p), opt, static_cast<boost::mpl::int_<1> const*>(0));
   1.347 +}
   1.348 +inline u32regex make_u32regex(const unsigned char* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl)
   1.349 +{
   1.350 +   return re_detail::do_make_u32regex(p, p + std::strlen(reinterpret_cast<const char*>(p)), opt, static_cast<boost::mpl::int_<1> const*>(0));
   1.351 +}
   1.352 +//
   1.353 +// construction from UTF-16 nul-terminated strings:
   1.354 +//
   1.355 +#ifndef BOOST_NO_WREGEX
   1.356 +inline u32regex make_u32regex(const wchar_t* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl)
   1.357 +{
   1.358 +   return re_detail::do_make_u32regex(p, p + std::wcslen(p), opt, static_cast<boost::mpl::int_<sizeof(wchar_t)> const*>(0));
   1.359 +}
   1.360 +#endif
   1.361 +#ifndef U_WCHAR_IS_UTF16
   1.362 +inline u32regex make_u32regex(const UChar* p, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl)
   1.363 +{
   1.364 +   return re_detail::do_make_u32regex(p, p + u_strlen(p), opt, static_cast<boost::mpl::int_<2> const*>(0));
   1.365 +}
   1.366 +#endif
   1.367 +//
   1.368 +// construction from basic_string class-template:
   1.369 +//
   1.370 +template<class C, class T, class A>
   1.371 +inline u32regex make_u32regex(const std::basic_string<C, T, A>& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl)
   1.372 +{
   1.373 +   return re_detail::do_make_u32regex(s.begin(), s.end(), opt, static_cast<boost::mpl::int_<sizeof(C)> const*>(0));
   1.374 +}
   1.375 +//
   1.376 +// Construction from ICU string type:
   1.377 +//
   1.378 +inline u32regex make_u32regex(const UnicodeString& s, boost::regex_constants::syntax_option_type opt = boost::regex_constants::perl)
   1.379 +{
   1.380 +   return re_detail::do_make_u32regex(s.getBuffer(), s.getBuffer() + s.length(), opt, static_cast<boost::mpl::int_<2> const*>(0));
   1.381 +}
   1.382 +
   1.383 +//
   1.384 +// regex_match overloads that widen the character type as appropriate:
   1.385 +//
   1.386 +namespace re_detail{
   1.387 +template<class MR1, class MR2>
   1.388 +void copy_results(MR1& out, MR2 const& in)
   1.389 +{
   1.390 +   // copy results from an adapted MR2 match_results:
   1.391 +   out.set_size(in.size(), in.prefix().first.base(), in.suffix().second.base());
   1.392 +   out.set_base(in.base().base());
   1.393 +   for(int i = 0; i < (int)in.size(); ++i)
   1.394 +   {
   1.395 +      if(in[i].matched)
   1.396 +      {
   1.397 +         out.set_first(in[i].first.base(), i);
   1.398 +         out.set_second(in[i].second.base(), i);
   1.399 +      }
   1.400 +   }
   1.401 +}
   1.402 +
   1.403 +template <class BidiIterator, class Allocator>
   1.404 +inline bool do_regex_match(BidiIterator first, BidiIterator last, 
   1.405 +                 match_results<BidiIterator, Allocator>& m, 
   1.406 +                 const u32regex& e, 
   1.407 +                 match_flag_type flags,
   1.408 +                 boost::mpl::int_<4> const*)
   1.409 +{
   1.410 +   return ::boost::regex_match(first, last, m, e, flags);
   1.411 +}
   1.412 +template <class BidiIterator, class Allocator>
   1.413 +bool do_regex_match(BidiIterator first, BidiIterator last, 
   1.414 +                 match_results<BidiIterator, Allocator>& m, 
   1.415 +                 const u32regex& e, 
   1.416 +                 match_flag_type flags,
   1.417 +                 boost::mpl::int_<2> const*)
   1.418 +{
   1.419 +   typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type;
   1.420 +   typedef match_results<conv_type>                   match_type;
   1.421 +   typedef typename match_type::allocator_type        alloc_type;
   1.422 +   match_type what;
   1.423 +   bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags);
   1.424 +   // copy results across to m:
   1.425 +   if(result) copy_results(m, what);
   1.426 +   return result;
   1.427 +}
   1.428 +template <class BidiIterator, class Allocator>
   1.429 +bool do_regex_match(BidiIterator first, BidiIterator last, 
   1.430 +                 match_results<BidiIterator, Allocator>& m, 
   1.431 +                 const u32regex& e, 
   1.432 +                 match_flag_type flags,
   1.433 +                 boost::mpl::int_<1> const*)
   1.434 +{
   1.435 +   typedef u8_to_u32_iterator<BidiIterator, UChar32>  conv_type;
   1.436 +   typedef match_results<conv_type>                   match_type;
   1.437 +   typedef typename match_type::allocator_type        alloc_type;
   1.438 +   match_type what;
   1.439 +   bool result = ::boost::regex_match(conv_type(first), conv_type(last), what, e, flags);
   1.440 +   // copy results across to m:
   1.441 +   if(result) copy_results(m, what);
   1.442 +   return result;
   1.443 +}
   1.444 +} // namespace re_detail
   1.445 +
   1.446 +template <class BidiIterator, class Allocator>
   1.447 +inline bool u32regex_match(BidiIterator first, BidiIterator last, 
   1.448 +                 match_results<BidiIterator, Allocator>& m, 
   1.449 +                 const u32regex& e, 
   1.450 +                 match_flag_type flags = match_default)
   1.451 +{
   1.452 +   return re_detail::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0));
   1.453 +}
   1.454 +inline bool u32regex_match(const UChar* p, 
   1.455 +                 match_results<const UChar*>& m, 
   1.456 +                 const u32regex& e, 
   1.457 +                 match_flag_type flags = match_default)
   1.458 +{
   1.459 +   return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0));
   1.460 +}
   1.461 +#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX)
   1.462 +inline bool u32regex_match(const wchar_t* p, 
   1.463 +                 match_results<const wchar_t*>& m, 
   1.464 +                 const u32regex& e, 
   1.465 +                 match_flag_type flags = match_default)
   1.466 +{
   1.467 +   return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.468 +}
   1.469 +#endif
   1.470 +inline bool u32regex_match(const char* p, 
   1.471 +                 match_results<const char*>& m, 
   1.472 +                 const u32regex& e, 
   1.473 +                 match_flag_type flags = match_default)
   1.474 +{
   1.475 +   return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0));
   1.476 +}
   1.477 +inline bool u32regex_match(const unsigned char* p, 
   1.478 +                 match_results<const unsigned char*>& m, 
   1.479 +                 const u32regex& e, 
   1.480 +                 match_flag_type flags = match_default)
   1.481 +{
   1.482 +   return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0));
   1.483 +}
   1.484 +inline bool u32regex_match(const std::string& s, 
   1.485 +                        match_results<std::string::const_iterator>& m, 
   1.486 +                        const u32regex& e, 
   1.487 +                        match_flag_type flags = match_default)
   1.488 +{
   1.489 +   return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0));
   1.490 +}
   1.491 +#ifndef BOOST_NO_STD_WSTRING
   1.492 +inline bool u32regex_match(const std::wstring& s, 
   1.493 +                        match_results<std::wstring::const_iterator>& m, 
   1.494 +                        const u32regex& e, 
   1.495 +                        match_flag_type flags = match_default)
   1.496 +{
   1.497 +   return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.498 +}
   1.499 +#endif
   1.500 +inline bool u32regex_match(const UnicodeString& s, 
   1.501 +                        match_results<const UChar*>& m, 
   1.502 +                        const u32regex& e, 
   1.503 +                        match_flag_type flags = match_default)
   1.504 +{
   1.505 +   return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.506 +}
   1.507 +//
   1.508 +// regex_match overloads that do not return what matched:
   1.509 +//
   1.510 +template <class BidiIterator>
   1.511 +inline bool u32regex_match(BidiIterator first, BidiIterator last, 
   1.512 +                 const u32regex& e, 
   1.513 +                 match_flag_type flags = match_default)
   1.514 +{
   1.515 +   match_results<BidiIterator> m;
   1.516 +   return re_detail::do_regex_match(first, last, m, e, flags, static_cast<mpl::int_<sizeof(*first)> const*>(0));
   1.517 +}
   1.518 +inline bool u32regex_match(const UChar* p, 
   1.519 +                 const u32regex& e, 
   1.520 +                 match_flag_type flags = match_default)
   1.521 +{
   1.522 +   match_results<const UChar*> m;
   1.523 +   return re_detail::do_regex_match(p, p+u_strlen(p), m, e, flags, static_cast<mpl::int_<2> const*>(0));
   1.524 +}
   1.525 +#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX)
   1.526 +inline bool u32regex_match(const wchar_t* p, 
   1.527 +                 const u32regex& e, 
   1.528 +                 match_flag_type flags = match_default)
   1.529 +{
   1.530 +   match_results<const wchar_t*> m;
   1.531 +   return re_detail::do_regex_match(p, p+std::wcslen(p), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.532 +}
   1.533 +#endif
   1.534 +inline bool u32regex_match(const char* p, 
   1.535 +                 const u32regex& e, 
   1.536 +                 match_flag_type flags = match_default)
   1.537 +{
   1.538 +   match_results<const char*> m;
   1.539 +   return re_detail::do_regex_match(p, p+std::strlen(p), m, e, flags, static_cast<mpl::int_<1> const*>(0));
   1.540 +}
   1.541 +inline bool u32regex_match(const unsigned char* p, 
   1.542 +                 const u32regex& e, 
   1.543 +                 match_flag_type flags = match_default)
   1.544 +{
   1.545 +   match_results<const unsigned char*> m;
   1.546 +   return re_detail::do_regex_match(p, p+std::strlen((const char*)p), m, e, flags, static_cast<mpl::int_<1> const*>(0));
   1.547 +}
   1.548 +inline bool u32regex_match(const std::string& s, 
   1.549 +                        const u32regex& e, 
   1.550 +                        match_flag_type flags = match_default)
   1.551 +{
   1.552 +   match_results<std::string::const_iterator> m;
   1.553 +   return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<1> const*>(0));
   1.554 +}
   1.555 +#ifndef BOOST_NO_STD_WSTRING
   1.556 +inline bool u32regex_match(const std::wstring& s, 
   1.557 +                        const u32regex& e, 
   1.558 +                        match_flag_type flags = match_default)
   1.559 +{
   1.560 +   match_results<std::wstring::const_iterator> m;
   1.561 +   return re_detail::do_regex_match(s.begin(), s.end(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.562 +}
   1.563 +#endif
   1.564 +inline bool u32regex_match(const UnicodeString& s, 
   1.565 +                        const u32regex& e, 
   1.566 +                        match_flag_type flags = match_default)
   1.567 +{
   1.568 +   match_results<const UChar*> m;
   1.569 +   return re_detail::do_regex_match(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.570 +}
   1.571 +
   1.572 +//
   1.573 +// regex_search overloads that widen the character type as appropriate:
   1.574 +//
   1.575 +namespace re_detail{
   1.576 +template <class BidiIterator, class Allocator>
   1.577 +inline bool do_regex_search(BidiIterator first, BidiIterator last, 
   1.578 +                 match_results<BidiIterator, Allocator>& m, 
   1.579 +                 const u32regex& e, 
   1.580 +                 match_flag_type flags,
   1.581 +                 BidiIterator base,
   1.582 +                 boost::mpl::int_<4> const*)
   1.583 +{
   1.584 +   return ::boost::regex_search(first, last, m, e, flags, base);
   1.585 +}
   1.586 +template <class BidiIterator, class Allocator>
   1.587 +bool do_regex_search(BidiIterator first, BidiIterator last, 
   1.588 +                 match_results<BidiIterator, Allocator>& m, 
   1.589 +                 const u32regex& e, 
   1.590 +                 match_flag_type flags,
   1.591 +                 BidiIterator base,
   1.592 +                 boost::mpl::int_<2> const*)
   1.593 +{
   1.594 +   typedef u16_to_u32_iterator<BidiIterator, UChar32> conv_type;
   1.595 +   typedef match_results<conv_type>                   match_type;
   1.596 +   typedef typename match_type::allocator_type        alloc_type;
   1.597 +   match_type what;
   1.598 +   bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base));
   1.599 +   // copy results across to m:
   1.600 +   if(result) copy_results(m, what);
   1.601 +   return result;
   1.602 +}
   1.603 +template <class BidiIterator, class Allocator>
   1.604 +bool do_regex_search(BidiIterator first, BidiIterator last, 
   1.605 +                 match_results<BidiIterator, Allocator>& m, 
   1.606 +                 const u32regex& e, 
   1.607 +                 match_flag_type flags,
   1.608 +                 BidiIterator base,
   1.609 +                 boost::mpl::int_<1> const*)
   1.610 +{
   1.611 +   typedef u8_to_u32_iterator<BidiIterator, UChar32>  conv_type;
   1.612 +   typedef match_results<conv_type>                   match_type;
   1.613 +   typedef typename match_type::allocator_type        alloc_type;
   1.614 +   match_type what;
   1.615 +   bool result = ::boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base));
   1.616 +   // copy results across to m:
   1.617 +   if(result) copy_results(m, what);
   1.618 +   return result;
   1.619 +}
   1.620 +}
   1.621 +
   1.622 +template <class BidiIterator, class Allocator>
   1.623 +inline bool u32regex_search(BidiIterator first, BidiIterator last, 
   1.624 +                 match_results<BidiIterator, Allocator>& m, 
   1.625 +                 const u32regex& e, 
   1.626 +                 match_flag_type flags = match_default)
   1.627 +{
   1.628 +   return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0));
   1.629 +}
   1.630 +template <class BidiIterator, class Allocator>
   1.631 +inline bool u32regex_search(BidiIterator first, BidiIterator last, 
   1.632 +                 match_results<BidiIterator, Allocator>& m, 
   1.633 +                 const u32regex& e, 
   1.634 +                 match_flag_type flags,
   1.635 +                 BidiIterator base)
   1.636 +{
   1.637 +   return re_detail::do_regex_search(first, last, m, e, flags, base, static_cast<mpl::int_<sizeof(*first)> const*>(0));
   1.638 +}
   1.639 +inline bool u32regex_search(const UChar* p, 
   1.640 +                 match_results<const UChar*>& m, 
   1.641 +                 const u32regex& e, 
   1.642 +                 match_flag_type flags = match_default)
   1.643 +{
   1.644 +   return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0));
   1.645 +}
   1.646 +#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX)
   1.647 +inline bool u32regex_search(const wchar_t* p, 
   1.648 +                 match_results<const wchar_t*>& m, 
   1.649 +                 const u32regex& e, 
   1.650 +                 match_flag_type flags = match_default)
   1.651 +{
   1.652 +   return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.653 +}
   1.654 +#endif
   1.655 +inline bool u32regex_search(const char* p, 
   1.656 +                 match_results<const char*>& m, 
   1.657 +                 const u32regex& e, 
   1.658 +                 match_flag_type flags = match_default)
   1.659 +{
   1.660 +   return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0));
   1.661 +}
   1.662 +inline bool u32regex_search(const unsigned char* p, 
   1.663 +                 match_results<const unsigned char*>& m, 
   1.664 +                 const u32regex& e, 
   1.665 +                 match_flag_type flags = match_default)
   1.666 +{
   1.667 +   return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0));
   1.668 +}
   1.669 +inline bool u32regex_search(const std::string& s, 
   1.670 +                        match_results<std::string::const_iterator>& m, 
   1.671 +                        const u32regex& e, 
   1.672 +                        match_flag_type flags = match_default)
   1.673 +{
   1.674 +   return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0));
   1.675 +}
   1.676 +#ifndef BOOST_NO_STD_WSTRING
   1.677 +inline bool u32regex_search(const std::wstring& s, 
   1.678 +                        match_results<std::wstring::const_iterator>& m, 
   1.679 +                        const u32regex& e, 
   1.680 +                        match_flag_type flags = match_default)
   1.681 +{
   1.682 +   return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.683 +}
   1.684 +#endif
   1.685 +inline bool u32regex_search(const UnicodeString& s, 
   1.686 +                        match_results<const UChar*>& m, 
   1.687 +                        const u32regex& e, 
   1.688 +                        match_flag_type flags = match_default)
   1.689 +{
   1.690 +   return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.691 +}
   1.692 +template <class BidiIterator>
   1.693 +inline bool u32regex_search(BidiIterator first, BidiIterator last, 
   1.694 +                 const u32regex& e, 
   1.695 +                 match_flag_type flags = match_default)
   1.696 +{
   1.697 +   match_results<BidiIterator> m;
   1.698 +   return re_detail::do_regex_search(first, last, m, e, flags, first, static_cast<mpl::int_<sizeof(*first)> const*>(0));
   1.699 +}
   1.700 +inline bool u32regex_search(const UChar* p, 
   1.701 +                 const u32regex& e, 
   1.702 +                 match_flag_type flags = match_default)
   1.703 +{
   1.704 +   match_results<const UChar*> m;
   1.705 +   return re_detail::do_regex_search(p, p+u_strlen(p), m, e, flags, p, static_cast<mpl::int_<2> const*>(0));
   1.706 +}
   1.707 +#if !defined(U_WCHAR_IS_UTF16) && !defined(BOOST_NO_WREGEX)
   1.708 +inline bool u32regex_search(const wchar_t* p, 
   1.709 +                 const u32regex& e, 
   1.710 +                 match_flag_type flags = match_default)
   1.711 +{
   1.712 +   match_results<const wchar_t*> m;
   1.713 +   return re_detail::do_regex_search(p, p+std::wcslen(p), m, e, flags, p, static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.714 +}
   1.715 +#endif
   1.716 +inline bool u32regex_search(const char* p, 
   1.717 +                 const u32regex& e, 
   1.718 +                 match_flag_type flags = match_default)
   1.719 +{
   1.720 +   match_results<const char*> m;
   1.721 +   return re_detail::do_regex_search(p, p+std::strlen(p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0));
   1.722 +}
   1.723 +inline bool u32regex_search(const unsigned char* p, 
   1.724 +                 const u32regex& e, 
   1.725 +                 match_flag_type flags = match_default)
   1.726 +{
   1.727 +   match_results<const unsigned char*> m;
   1.728 +   return re_detail::do_regex_search(p, p+std::strlen((const char*)p), m, e, flags, p, static_cast<mpl::int_<1> const*>(0));
   1.729 +}
   1.730 +inline bool u32regex_search(const std::string& s, 
   1.731 +                        const u32regex& e, 
   1.732 +                        match_flag_type flags = match_default)
   1.733 +{
   1.734 +   match_results<std::string::const_iterator> m;
   1.735 +   return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<1> const*>(0));
   1.736 +}
   1.737 +#ifndef BOOST_NO_STD_WSTRING
   1.738 +inline bool u32regex_search(const std::wstring& s, 
   1.739 +                        const u32regex& e, 
   1.740 +                        match_flag_type flags = match_default)
   1.741 +{
   1.742 +   match_results<std::wstring::const_iterator> m;
   1.743 +   return re_detail::do_regex_search(s.begin(), s.end(), m, e, flags, s.begin(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.744 +}
   1.745 +#endif
   1.746 +inline bool u32regex_search(const UnicodeString& s, 
   1.747 +                        const u32regex& e, 
   1.748 +                        match_flag_type flags = match_default)
   1.749 +{
   1.750 +   match_results<const UChar*> m;
   1.751 +   return re_detail::do_regex_search(s.getBuffer(), s.getBuffer() + s.length(), m, e, flags, s.getBuffer(), static_cast<mpl::int_<sizeof(wchar_t)> const*>(0));
   1.752 +}
   1.753 +
   1.754 +//
   1.755 +// overloads for regex_replace with utf-8 and utf-16 data types:
   1.756 +//
   1.757 +namespace re_detail{
   1.758 +template <class I>
   1.759 +inline std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >
   1.760 +   make_utf32_seq(I i, I j, mpl::int_<1> const*)
   1.761 +{
   1.762 +   return std::pair< boost::u8_to_u32_iterator<I>, boost::u8_to_u32_iterator<I> >(boost::u8_to_u32_iterator<I>(i), boost::u8_to_u32_iterator<I>(j));
   1.763 +}
   1.764 +template <class I>
   1.765 +inline std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >
   1.766 +   make_utf32_seq(I i, I j, mpl::int_<2> const*)
   1.767 +{
   1.768 +   return std::pair< boost::u16_to_u32_iterator<I>, boost::u16_to_u32_iterator<I> >(boost::u16_to_u32_iterator<I>(i), boost::u16_to_u32_iterator<I>(j));
   1.769 +}
   1.770 +template <class I>
   1.771 +inline std::pair< I, I >
   1.772 +   make_utf32_seq(I i, I j, mpl::int_<4> const*)
   1.773 +{
   1.774 +   return std::pair< I, I >(i, j);
   1.775 +}
   1.776 +template <class charT>
   1.777 +inline std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >
   1.778 +   make_utf32_seq(const charT* p, mpl::int_<1> const*)
   1.779 +{
   1.780 +   return std::pair< boost::u8_to_u32_iterator<const charT*>, boost::u8_to_u32_iterator<const charT*> >(boost::u8_to_u32_iterator<const charT*>(p), boost::u8_to_u32_iterator<const charT*>(p+std::strlen((const char*)p)));
   1.781 +}
   1.782 +template <class charT>
   1.783 +inline std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >
   1.784 +   make_utf32_seq(const charT* p, mpl::int_<2> const*)
   1.785 +{
   1.786 +   return std::pair< boost::u16_to_u32_iterator<const charT*>, boost::u16_to_u32_iterator<const charT*> >(boost::u16_to_u32_iterator<const charT*>(p), boost::u16_to_u32_iterator<const charT*>(p+u_strlen((const UChar*)p)));
   1.787 +}
   1.788 +template <class charT>
   1.789 +inline std::pair< const charT*, const charT* >
   1.790 +   make_utf32_seq(const charT* p, mpl::int_<4> const*)
   1.791 +{
   1.792 +   return std::pair< const charT*, const charT* >(p, p+icu_regex_traits::length((UChar32 const*)p));
   1.793 +}
   1.794 +template <class OutputIterator>
   1.795 +inline OutputIterator make_utf32_out(OutputIterator o, mpl::int_<4> const*)
   1.796 +{
   1.797 +   return o;
   1.798 +}
   1.799 +template <class OutputIterator>
   1.800 +inline utf16_output_iterator<OutputIterator> make_utf32_out(OutputIterator o, mpl::int_<2> const*)
   1.801 +{
   1.802 +   return o;
   1.803 +}
   1.804 +template <class OutputIterator>
   1.805 +inline utf8_output_iterator<OutputIterator> make_utf32_out(OutputIterator o, mpl::int_<1> const*)
   1.806 +{
   1.807 +   return o;
   1.808 +}
   1.809 +
   1.810 +template <class OutputIterator, class I1, class I2>
   1.811 +OutputIterator do_regex_replace(OutputIterator out,
   1.812 +                                 std::pair<I1, I1> const& in,
   1.813 +                                 const u32regex& e, 
   1.814 +                                 const std::pair<I2, I2>& fmt, 
   1.815 +                                 match_flag_type flags
   1.816 +                                 )
   1.817 +{
   1.818 +   // unfortunately we have to copy the format string in order to pass in onward:
   1.819 +   std::vector<UChar32> f;
   1.820 +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
   1.821 +   f.assign(fmt.first, fmt.second);
   1.822 +#else
   1.823 +   f.clear();
   1.824 +   I2 pos = fmt.first;
   1.825 +   while(pos != fmt.second)
   1.826 +      f.push_back(*pos++);
   1.827 +#endif
   1.828 +   
   1.829 +   regex_iterator<I1, UChar32, icu_regex_traits> i(in.first, in.second, e, flags);
   1.830 +   regex_iterator<I1, UChar32, icu_regex_traits> j;
   1.831 +   if(i == j)
   1.832 +   {
   1.833 +      if(!(flags & regex_constants::format_no_copy))
   1.834 +         out = re_detail::copy(in.first, in.second, out);
   1.835 +   }
   1.836 +   else
   1.837 +   {
   1.838 +      I1 last_m = in.first;
   1.839 +      while(i != j)
   1.840 +      {
   1.841 +         if(!(flags & regex_constants::format_no_copy))
   1.842 +            out = re_detail::copy(i->prefix().first, i->prefix().second, out); 
   1.843 +         if(f.size())
   1.844 +            out = ::boost::re_detail::regex_format_imp(out, *i, &*f.begin(), &*f.begin() + f.size(), flags, e.get_traits());
   1.845 +         else
   1.846 +            out = ::boost::re_detail::regex_format_imp(out, *i, static_cast<UChar32 const*>(0), static_cast<UChar32 const*>(0), flags, e.get_traits());
   1.847 +         last_m = (*i)[0].second;
   1.848 +         if(flags & regex_constants::format_first_only)
   1.849 +            break;
   1.850 +         ++i;
   1.851 +      }
   1.852 +      if(!(flags & regex_constants::format_no_copy))
   1.853 +         out = re_detail::copy(last_m, in.second, out);
   1.854 +   }
   1.855 +   return out;
   1.856 +}
   1.857 +template <class BaseIterator>
   1.858 +inline const BaseIterator& extract_output_base(const BaseIterator& b)
   1.859 +{
   1.860 +   return b;
   1.861 +}
   1.862 +template <class BaseIterator>
   1.863 +inline BaseIterator extract_output_base(const utf8_output_iterator<BaseIterator>& b)
   1.864 +{
   1.865 +   return b.base();
   1.866 +}
   1.867 +template <class BaseIterator>
   1.868 +inline BaseIterator extract_output_base(const utf16_output_iterator<BaseIterator>& b)
   1.869 +{
   1.870 +   return b.base();
   1.871 +}
   1.872 +}  // re_detail
   1.873 +
   1.874 +template <class OutputIterator, class BidirectionalIterator, class charT>
   1.875 +inline OutputIterator u32regex_replace(OutputIterator out,
   1.876 +                         BidirectionalIterator first,
   1.877 +                         BidirectionalIterator last,
   1.878 +                         const u32regex& e, 
   1.879 +                         const charT* fmt, 
   1.880 +                         match_flag_type flags = match_default)
   1.881 +{
   1.882 +   return re_detail::extract_output_base
   1.883 +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
   1.884 +   <OutputIterator>
   1.885 +#endif
   1.886 +    (
   1.887 +      re_detail::do_regex_replace(
   1.888 +         re_detail::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)),
   1.889 +         re_detail::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)),
   1.890 +         e,
   1.891 +         re_detail::make_utf32_seq(fmt, static_cast<mpl::int_<sizeof(*fmt)> const*>(0)),
   1.892 +         flags)
   1.893 +      );
   1.894 +}
   1.895 +
   1.896 +template <class OutputIterator, class Iterator, class charT>
   1.897 +inline OutputIterator u32regex_replace(OutputIterator out,
   1.898 +                         Iterator first,
   1.899 +                         Iterator last,
   1.900 +                         const u32regex& e, 
   1.901 +                         const std::basic_string<charT>& fmt,
   1.902 +                         match_flag_type flags = match_default)
   1.903 +{
   1.904 +   return re_detail::extract_output_base
   1.905 +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
   1.906 +   <OutputIterator>
   1.907 +#endif
   1.908 +    (
   1.909 +      re_detail::do_regex_replace(
   1.910 +         re_detail::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)),
   1.911 +         re_detail::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)),
   1.912 +         e,
   1.913 +         re_detail::make_utf32_seq(fmt.begin(), fmt.end(), static_cast<mpl::int_<sizeof(charT)> const*>(0)),
   1.914 +         flags)
   1.915 +      );
   1.916 +}
   1.917 +
   1.918 +template <class OutputIterator, class Iterator>
   1.919 +inline OutputIterator u32regex_replace(OutputIterator out,
   1.920 +                         Iterator first,
   1.921 +                         Iterator last,
   1.922 +                         const u32regex& e, 
   1.923 +                         const UnicodeString& fmt,
   1.924 +                         match_flag_type flags = match_default)
   1.925 +{
   1.926 +   return re_detail::extract_output_base
   1.927 +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
   1.928 +   <OutputIterator>
   1.929 +#endif
   1.930 +   (
   1.931 +      re_detail::do_regex_replace(
   1.932 +         re_detail::make_utf32_out(out, static_cast<mpl::int_<sizeof(*first)> const*>(0)),
   1.933 +         re_detail::make_utf32_seq(first, last, static_cast<mpl::int_<sizeof(*first)> const*>(0)),
   1.934 +         e,
   1.935 +         re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)),
   1.936 +         flags)
   1.937 +      );
   1.938 +}
   1.939 +
   1.940 +template <class charT>
   1.941 +std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s,
   1.942 +                         const u32regex& e, 
   1.943 +                         const charT* fmt,
   1.944 +                         match_flag_type flags = match_default)
   1.945 +{
   1.946 +   std::basic_string<charT> result;
   1.947 +   re_detail::string_out_iterator<std::basic_string<charT> > i(result);
   1.948 +   u32regex_replace(i, s.begin(), s.end(), e, fmt, flags);
   1.949 +   return result;
   1.950 +}
   1.951 +
   1.952 +template <class charT>
   1.953 +std::basic_string<charT> u32regex_replace(const std::basic_string<charT>& s,
   1.954 +                         const u32regex& e, 
   1.955 +                         const std::basic_string<charT>& fmt,
   1.956 +                         match_flag_type flags = match_default)
   1.957 +{
   1.958 +   std::basic_string<charT> result;
   1.959 +   re_detail::string_out_iterator<std::basic_string<charT> > i(result);
   1.960 +   u32regex_replace(i, s.begin(), s.end(), e, fmt.c_str(), flags);
   1.961 +   return result;
   1.962 +}
   1.963 +
   1.964 +namespace re_detail{
   1.965 +
   1.966 +class unicode_string_out_iterator
   1.967 +{
   1.968 +   UnicodeString* out;
   1.969 +public:
   1.970 +   unicode_string_out_iterator(UnicodeString& s) : out(&s) {}
   1.971 +   unicode_string_out_iterator& operator++() { return *this; }
   1.972 +   unicode_string_out_iterator& operator++(int) { return *this; }
   1.973 +   unicode_string_out_iterator& operator*() { return *this; }
   1.974 +   unicode_string_out_iterator& operator=(UChar v) 
   1.975 +   { 
   1.976 +      *out += v; 
   1.977 +      return *this; 
   1.978 +   }
   1.979 +   typedef std::ptrdiff_t difference_type;
   1.980 +   typedef UChar value_type;
   1.981 +   typedef value_type* pointer;
   1.982 +   typedef value_type& reference;
   1.983 +   typedef std::output_iterator_tag iterator_category;
   1.984 +};
   1.985 +
   1.986 +}
   1.987 +
   1.988 +inline UnicodeString u32regex_replace(const UnicodeString& s,
   1.989 +                         const u32regex& e, 
   1.990 +                         const UChar* fmt,
   1.991 +                         match_flag_type flags = match_default)
   1.992 +{
   1.993 +   UnicodeString result;
   1.994 +   re_detail::unicode_string_out_iterator i(result);
   1.995 +   u32regex_replace(i, s.getBuffer(), s.getBuffer()+s.length(), e, fmt, flags);
   1.996 +   return result;
   1.997 +}
   1.998 +
   1.999 +inline UnicodeString u32regex_replace(const UnicodeString& s,
  1.1000 +                         const u32regex& e, 
  1.1001 +                         const UnicodeString& fmt,
  1.1002 +                         match_flag_type flags = match_default)
  1.1003 +{
  1.1004 +   UnicodeString result;
  1.1005 +   re_detail::unicode_string_out_iterator i(result);
  1.1006 +   re_detail::do_regex_replace(
  1.1007 +         re_detail::make_utf32_out(i, static_cast<mpl::int_<2> const*>(0)),
  1.1008 +         re_detail::make_utf32_seq(s.getBuffer(), s.getBuffer()+s.length(), static_cast<mpl::int_<2> const*>(0)),
  1.1009 +         e,
  1.1010 +         re_detail::make_utf32_seq(fmt.getBuffer(), fmt.getBuffer() + fmt.length(), static_cast<mpl::int_<2> const*>(0)),
  1.1011 +         flags);
  1.1012 +   return result;
  1.1013 +}
  1.1014 +
  1.1015 +} // namespace boost.
  1.1016 +
  1.1017 +#include <boost/regex/v4/u32regex_iterator.hpp>
  1.1018 +#include <boost/regex/v4/u32regex_token_iterator.hpp>
  1.1019 +
  1.1020 +#endif