Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:20

0001 /*
0002  *
0003  * Copyright (c) 1998-2004 John Maddock
0004  * Copyright 2011 Garmin Ltd. or its subsidiaries
0005  *
0006  * Distributed under the Boost Software License, Version 1.0.
0007  * (See accompanying file LICENSE_1_0.txt or copy at
0008  * http://www.boost.org/LICENSE_1_0.txt)
0009  *
0010  */
0011 
0012  /*
0013   *   LOCATION:    see http://www.boost.org/ for most recent version.
0014   *   FILE         basic_regex.cpp
0015   *   VERSION      see <boost/version.hpp>
0016   *   DESCRIPTION: Declares template class basic_regex.
0017   */
0018 
0019 #ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP
0020 #define BOOST_REGEX_V4_BASIC_REGEX_HPP
0021 
0022 #include <boost/type_traits/is_same.hpp>
0023 #include <boost/container_hash/hash.hpp>
0024 
0025 #ifdef BOOST_MSVC
0026 #pragma warning(push)
0027 #pragma warning(disable: 4103)
0028 #endif
0029 #ifdef BOOST_HAS_ABI_HEADERS
0030 #  include BOOST_ABI_PREFIX
0031 #endif
0032 #ifdef BOOST_MSVC
0033 #pragma warning(pop)
0034 #endif
0035 
0036 namespace boost{
0037 #ifdef BOOST_MSVC
0038 #pragma warning(push)
0039 #pragma warning(disable : 4251)
0040 #if BOOST_MSVC < 1700
0041 #     pragma warning(disable : 4231)
0042 #endif
0043 #if BOOST_MSVC < 1600
0044 #pragma warning(disable : 4660)
0045 #endif
0046 #if BOOST_MSVC < 1910
0047 #pragma warning(disable:4800)
0048 #endif
0049 #endif
0050 
0051 namespace BOOST_REGEX_DETAIL_NS{
0052 
0053 //
0054 // forward declaration, we will need this one later:
0055 //
0056 template <class charT, class traits>
0057 class basic_regex_parser;
0058 
0059 template <class I>
0060 void bubble_down_one(I first, I last)
0061 {
0062    if(first != last)
0063    {
0064       I next = last - 1;
0065       while((next != first) && (*next < *(next-1)))
0066       {
0067          (next-1)->swap(*next);
0068          --next;
0069       }
0070    }
0071 }
0072 
0073 static const int hash_value_mask = 1 << (std::numeric_limits<int>::digits - 1);
0074 
0075 template <class Iterator>
0076 inline int hash_value_from_capture_name(Iterator i, Iterator j)
0077 {
0078    std::size_t r = boost::hash_range(i, j);
0079    r %= ((std::numeric_limits<int>::max)());
0080    return static_cast<int>(r) | hash_value_mask;
0081 }
0082 
0083 class named_subexpressions
0084 {
0085 public:
0086    struct name
0087    {
0088       template <class charT>
0089       name(const charT* i, const charT* j, int idx)
0090          : index(idx) 
0091       { 
0092          hash = hash_value_from_capture_name(i, j); 
0093       }
0094       name(int h, int idx)
0095          : index(idx), hash(h)
0096       { 
0097       }
0098       int index;
0099       int hash;
0100       bool operator < (const name& other)const
0101       {
0102          return hash < other.hash;
0103       }
0104       bool operator == (const name& other)const
0105       {
0106          return hash == other.hash; 
0107       }
0108       void swap(name& other)
0109       {
0110          std::swap(index, other.index);
0111          std::swap(hash, other.hash);
0112       }
0113    };
0114 
0115    typedef std::vector<name>::const_iterator const_iterator;
0116    typedef std::pair<const_iterator, const_iterator> range_type;
0117 
0118    named_subexpressions(){}
0119 
0120    template <class charT>
0121    void set_name(const charT* i, const charT* j, int index)
0122    {
0123       m_sub_names.push_back(name(i, j, index));
0124       bubble_down_one(m_sub_names.begin(), m_sub_names.end());
0125    }
0126    template <class charT>
0127    int get_id(const charT* i, const charT* j)const
0128    {
0129       name t(i, j, 0);
0130       typename std::vector<name>::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t);
0131       if((pos != m_sub_names.end()) && (*pos == t))
0132       {
0133          return pos->index;
0134       }
0135       return -1;
0136    }
0137    template <class charT>
0138    range_type equal_range(const charT* i, const charT* j)const
0139    {
0140       name t(i, j, 0);
0141       return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t);
0142    }
0143    int get_id(int h)const
0144    {
0145       name t(h, 0);
0146       std::vector<name>::const_iterator pos = std::lower_bound(m_sub_names.begin(), m_sub_names.end(), t);
0147       if((pos != m_sub_names.end()) && (*pos == t))
0148       {
0149          return pos->index;
0150       }
0151       return -1;
0152    }
0153    range_type equal_range(int h)const
0154    {
0155       name t(h, 0);
0156       return std::equal_range(m_sub_names.begin(), m_sub_names.end(), t);
0157    }
0158 private:
0159    std::vector<name> m_sub_names;
0160 };
0161 
0162 //
0163 // class regex_data:
0164 // represents the data we wish to expose to the matching algorithms.
0165 //
0166 template <class charT, class traits>
0167 struct regex_data : public named_subexpressions
0168 {
0169    typedef regex_constants::syntax_option_type   flag_type;
0170    typedef std::size_t                           size_type;  
0171 
0172    regex_data(const ::boost::shared_ptr<
0173       ::boost::regex_traits_wrapper<traits> >& t) 
0174       : m_ptraits(t), m_flags(0), m_status(0), m_expression(0), m_expression_len(0),
0175          m_mark_count(0), m_first_state(0), m_restart_type(0),
0176 #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) && !(defined(BOOST_MSVC) && (BOOST_MSVC < 1900))
0177          m_startmap{ 0 },
0178 #endif
0179          m_can_be_null(0), m_word_mask(0), m_has_recursions(false), m_disable_match_any(false) {}
0180    regex_data() 
0181       : m_ptraits(new ::boost::regex_traits_wrapper<traits>()), m_flags(0), m_status(0), m_expression(0), m_expression_len(0), 
0182          m_mark_count(0), m_first_state(0), m_restart_type(0), 
0183 #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) && !(defined(BOOST_MSVC) && (BOOST_MSVC < 1900))
0184       m_startmap{ 0 },
0185 #endif
0186          m_can_be_null(0), m_word_mask(0), m_has_recursions(false), m_disable_match_any(false) {}
0187 
0188    ::boost::shared_ptr<
0189       ::boost::regex_traits_wrapper<traits>
0190       >                        m_ptraits;                 // traits class instance
0191    flag_type                   m_flags;                   // flags with which we were compiled
0192    int                         m_status;                  // error code (0 implies OK).
0193    const charT*                m_expression;              // the original expression
0194    std::ptrdiff_t              m_expression_len;          // the length of the original expression
0195    size_type                   m_mark_count;              // the number of marked sub-expressions
0196    BOOST_REGEX_DETAIL_NS::re_syntax_base*  m_first_state;             // the first state of the machine
0197    unsigned                    m_restart_type;            // search optimisation type
0198    unsigned char               m_startmap[1 << CHAR_BIT]; // which characters can start a match
0199    unsigned int                m_can_be_null;             // whether we can match a null string
0200    BOOST_REGEX_DETAIL_NS::raw_storage      m_data;                    // the buffer in which our states are constructed
0201    typename traits::char_class_type    m_word_mask;       // mask used to determine if a character is a word character
0202    std::vector<
0203       std::pair<
0204       std::size_t, std::size_t> > m_subs;                 // Position of sub-expressions within the *string*.
0205    bool                        m_has_recursions;          // whether we have recursive expressions;
0206    bool                        m_disable_match_any;       // when set we need to disable the match_any flag as it causes different/buggy behaviour.
0207 };
0208 //
0209 // class basic_regex_implementation
0210 // pimpl implementation class for basic_regex.
0211 //
0212 template <class charT, class traits>
0213 class basic_regex_implementation
0214    : public regex_data<charT, traits>
0215 {
0216 public:
0217    typedef regex_constants::syntax_option_type   flag_type;
0218    typedef std::ptrdiff_t                        difference_type;
0219    typedef std::size_t                           size_type; 
0220    typedef typename traits::locale_type          locale_type;
0221    typedef const charT*                          const_iterator;
0222 
0223    basic_regex_implementation(){}
0224    basic_regex_implementation(const ::boost::shared_ptr<
0225       ::boost::regex_traits_wrapper<traits> >& t)
0226       : regex_data<charT, traits>(t) {}
0227    void assign(const charT* arg_first,
0228                           const charT* arg_last,
0229                           flag_type f)
0230    {
0231       regex_data<charT, traits>* pdat = this;
0232       basic_regex_parser<charT, traits> parser(pdat);
0233       parser.parse(arg_first, arg_last, f);
0234    }
0235 
0236    locale_type BOOST_REGEX_CALL imbue(locale_type l)
0237    { 
0238       return this->m_ptraits->imbue(l); 
0239    }
0240    locale_type BOOST_REGEX_CALL getloc()const
0241    { 
0242       return this->m_ptraits->getloc(); 
0243    }
0244    std::basic_string<charT> BOOST_REGEX_CALL str()const
0245    {
0246       std::basic_string<charT> result;
0247       if(this->m_status == 0)
0248          result = std::basic_string<charT>(this->m_expression, this->m_expression_len);
0249       return result;
0250    }
0251    const_iterator BOOST_REGEX_CALL expression()const
0252    {
0253       return this->m_expression;
0254    }
0255    std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
0256    {
0257       const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n);
0258       std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
0259       return p;
0260    }
0261    //
0262    // begin, end:
0263    const_iterator BOOST_REGEX_CALL begin()const
0264    { 
0265       return (this->m_status ? 0 : this->m_expression); 
0266    }
0267    const_iterator BOOST_REGEX_CALL end()const
0268    { 
0269       return (this->m_status ? 0 : this->m_expression + this->m_expression_len); 
0270    }
0271    flag_type BOOST_REGEX_CALL flags()const
0272    {
0273       return this->m_flags;
0274    }
0275    size_type BOOST_REGEX_CALL size()const
0276    {
0277       return this->m_expression_len;
0278    }
0279    int BOOST_REGEX_CALL status()const
0280    {
0281       return this->m_status;
0282    }
0283    size_type BOOST_REGEX_CALL mark_count()const
0284    {
0285       return this->m_mark_count - 1;
0286    }
0287    const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const
0288    {
0289       return this->m_first_state;
0290    }
0291    unsigned get_restart_type()const
0292    {
0293       return this->m_restart_type;
0294    }
0295    const unsigned char* get_map()const
0296    {
0297       return this->m_startmap;
0298    }
0299    const ::boost::regex_traits_wrapper<traits>& get_traits()const
0300    {
0301       return *(this->m_ptraits);
0302    }
0303    bool can_be_null()const
0304    {
0305       return this->m_can_be_null;
0306    }
0307    const regex_data<charT, traits>& get_data()const
0308    {
0309       basic_regex_implementation<charT, traits> const* p = this;
0310       return *static_cast<const regex_data<charT, traits>*>(p);
0311    }
0312 };
0313 
0314 } // namespace BOOST_REGEX_DETAIL_NS
0315 //
0316 // class basic_regex:
0317 // represents the compiled
0318 // regular expression:
0319 //
0320 
0321 #ifdef BOOST_REGEX_NO_FWD
0322 template <class charT, class traits = regex_traits<charT> >
0323 #else
0324 template <class charT, class traits >
0325 #endif
0326 class basic_regex : public regbase
0327 {
0328 public:
0329    // typedefs:
0330    typedef std::size_t                           traits_size_type;
0331    typedef typename traits::string_type          traits_string_type;
0332    typedef charT                                 char_type;
0333    typedef traits                                traits_type;
0334 
0335    typedef charT                                 value_type;
0336    typedef charT&                                reference;
0337    typedef const charT&                          const_reference;
0338    typedef const charT*                          const_iterator;
0339    typedef const_iterator                        iterator;
0340    typedef std::ptrdiff_t                        difference_type;
0341    typedef std::size_t                           size_type;   
0342    typedef regex_constants::syntax_option_type   flag_type;
0343    // locale_type
0344    // placeholder for actual locale type used by the
0345    // traits class to localise *this.
0346    typedef typename traits::locale_type          locale_type;
0347    
0348 public:
0349    explicit basic_regex(){}
0350    explicit basic_regex(const charT* p, flag_type f = regex_constants::normal)
0351    {
0352       assign(p, f);
0353    }
0354    basic_regex(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
0355    {
0356       assign(p1, p2, f);
0357    }
0358    basic_regex(const charT* p, size_type len, flag_type f)
0359    {
0360       assign(p, len, f);
0361    }
0362    basic_regex(const basic_regex& that)
0363       : m_pimpl(that.m_pimpl) {}
0364    ~basic_regex(){}
0365    basic_regex& BOOST_REGEX_CALL operator=(const basic_regex& that)
0366    {
0367       return assign(that);
0368    }
0369    basic_regex& BOOST_REGEX_CALL operator=(const charT* ptr)
0370    {
0371       return assign(ptr);
0372    }
0373 
0374    //
0375    // assign:
0376    basic_regex& assign(const basic_regex& that)
0377    { 
0378       m_pimpl = that.m_pimpl;
0379       return *this; 
0380    }
0381    basic_regex& assign(const charT* p, flag_type f = regex_constants::normal)
0382    {
0383       return assign(p, p + traits::length(p), f);
0384    }
0385    basic_regex& assign(const charT* p, size_type len, flag_type f)
0386    {
0387       return assign(p, p + len, f);
0388    }
0389 private:
0390    basic_regex& do_assign(const charT* p1,
0391                           const charT* p2,
0392                           flag_type f);
0393 public:
0394    basic_regex& assign(const charT* p1,
0395                           const charT* p2,
0396                           flag_type f = regex_constants::normal)
0397    {
0398       return do_assign(p1, p2, f);
0399    }
0400 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
0401 
0402    template <class ST, class SA>
0403    unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
0404    { 
0405       return set_expression(p.data(), p.data() + p.size(), f); 
0406    }
0407 
0408    template <class ST, class SA>
0409    explicit basic_regex(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
0410    { 
0411       assign(p, f); 
0412    }
0413 
0414    template <class InputIterator>
0415    basic_regex(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal)
0416    {
0417       typedef typename traits::string_type seq_type;
0418       seq_type a(arg_first, arg_last);
0419       if(!a.empty())
0420          assign(static_cast<const charT*>(&*a.begin()), static_cast<const charT*>(&*a.begin() + a.size()), f);
0421       else
0422          assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
0423    }
0424 
0425    template <class ST, class SA>
0426    basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
0427    {
0428       return assign(p.data(), p.data() + p.size(), regex_constants::normal);
0429    }
0430 
0431    template <class string_traits, class A>
0432    basic_regex& BOOST_REGEX_CALL assign(
0433        const std::basic_string<charT, string_traits, A>& s,
0434        flag_type f = regex_constants::normal)
0435    {
0436       return assign(s.data(), s.data() + s.size(), f);
0437    }
0438 
0439    template <class InputIterator>
0440    basic_regex& BOOST_REGEX_CALL assign(InputIterator arg_first,
0441                           InputIterator arg_last,
0442                           flag_type f = regex_constants::normal)
0443    {
0444       typedef typename traits::string_type seq_type;
0445       seq_type a(arg_first, arg_last);
0446       if(a.size())
0447       {
0448          const charT* p1 = &*a.begin();
0449          const charT* p2 = &*a.begin() + a.size();
0450          return assign(p1, p2, f);
0451       }
0452       return assign(static_cast<const charT*>(0), static_cast<const charT*>(0), f);
0453    }
0454 #else
0455    unsigned int BOOST_REGEX_CALL set_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
0456    { 
0457       return set_expression(p.data(), p.data() + p.size(), f); 
0458    }
0459 
0460    basic_regex(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
0461    { 
0462       assign(p, f); 
0463    }
0464 
0465    basic_regex& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
0466    {
0467       return assign(p.data(), p.data() + p.size(), regex_constants::normal);
0468    }
0469 
0470    basic_regex& BOOST_REGEX_CALL assign(
0471        const std::basic_string<charT>& s,
0472        flag_type f = regex_constants::normal)
0473    {
0474       return assign(s.data(), s.data() + s.size(), f);
0475    }
0476 
0477 #endif
0478 
0479    //
0480    // locale:
0481    locale_type BOOST_REGEX_CALL imbue(locale_type l);
0482    locale_type BOOST_REGEX_CALL getloc()const
0483    { 
0484       return m_pimpl.get() ? m_pimpl->getloc() : locale_type(); 
0485    }
0486    //
0487    // getflags:
0488    // retained for backwards compatibility only, "flags"
0489    // is now the preferred name:
0490    flag_type BOOST_REGEX_CALL getflags()const
0491    { 
0492       return flags();
0493    }
0494    flag_type BOOST_REGEX_CALL flags()const
0495    { 
0496       return m_pimpl.get() ? m_pimpl->flags() : 0;
0497    }
0498    //
0499    // str:
0500    std::basic_string<charT> BOOST_REGEX_CALL str()const
0501    {
0502       return m_pimpl.get() ? m_pimpl->str() : std::basic_string<charT>();
0503    }
0504    //
0505    // begin, end, subexpression:
0506    std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
0507    {
0508       if(!m_pimpl.get())
0509          boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex."));
0510       return m_pimpl->subexpression(n);
0511    }
0512    const_iterator BOOST_REGEX_CALL begin()const
0513    { 
0514       return (m_pimpl.get() ? m_pimpl->begin() : 0); 
0515    }
0516    const_iterator BOOST_REGEX_CALL end()const
0517    { 
0518       return (m_pimpl.get() ? m_pimpl->end() : 0); 
0519    }
0520    //
0521    // swap:
0522    void BOOST_REGEX_CALL swap(basic_regex& that)throw()
0523    {
0524       m_pimpl.swap(that.m_pimpl);
0525    }
0526    //
0527    // size:
0528    size_type BOOST_REGEX_CALL size()const
0529    { 
0530       return (m_pimpl.get() ? m_pimpl->size() : 0); 
0531    }
0532    //
0533    // max_size:
0534    size_type BOOST_REGEX_CALL max_size()const
0535    { 
0536       return UINT_MAX; 
0537    }
0538    //
0539    // empty:
0540    bool BOOST_REGEX_CALL empty()const
0541    { 
0542       return (m_pimpl.get() ? 0 != m_pimpl->status() : true); 
0543    }
0544 
0545    size_type BOOST_REGEX_CALL mark_count()const 
0546    { 
0547       return (m_pimpl.get() ? m_pimpl->mark_count() : 0); 
0548    }
0549 
0550    int status()const
0551    {
0552       return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty);
0553    }
0554 
0555    int BOOST_REGEX_CALL compare(const basic_regex& that) const
0556    {
0557       if(m_pimpl.get() == that.m_pimpl.get())
0558          return 0;
0559       if(!m_pimpl.get())
0560          return -1;
0561       if(!that.m_pimpl.get())
0562          return 1;
0563       if(status() != that.status())
0564          return status() - that.status();
0565       if(flags() != that.flags())
0566          return flags() - that.flags();
0567       return str().compare(that.str());
0568    }
0569    bool BOOST_REGEX_CALL operator==(const basic_regex& e)const
0570    { 
0571       return compare(e) == 0; 
0572    }
0573    bool BOOST_REGEX_CALL operator != (const basic_regex& e)const
0574    { 
0575       return compare(e) != 0; 
0576    }
0577    bool BOOST_REGEX_CALL operator<(const basic_regex& e)const
0578    { 
0579       return compare(e) < 0; 
0580    }
0581    bool BOOST_REGEX_CALL operator>(const basic_regex& e)const
0582    { 
0583       return compare(e) > 0; 
0584    }
0585    bool BOOST_REGEX_CALL operator<=(const basic_regex& e)const
0586    { 
0587       return compare(e) <= 0; 
0588    }
0589    bool BOOST_REGEX_CALL operator>=(const basic_regex& e)const
0590    { 
0591       return compare(e) >= 0; 
0592    }
0593 
0594    //
0595    // The following are deprecated as public interfaces
0596    // but are available for compatibility with earlier versions.
0597    const charT* BOOST_REGEX_CALL expression()const 
0598    { 
0599       return (m_pimpl.get() && !m_pimpl->status() ? m_pimpl->expression() : 0); 
0600    }
0601    unsigned int BOOST_REGEX_CALL set_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
0602    {
0603       assign(p1, p2, f | regex_constants::no_except);
0604       return status();
0605    }
0606    unsigned int BOOST_REGEX_CALL set_expression(const charT* p, flag_type f = regex_constants::normal) 
0607    { 
0608       assign(p, f | regex_constants::no_except); 
0609       return status();
0610    }
0611    unsigned int BOOST_REGEX_CALL error_code()const
0612    {
0613       return status();
0614    }
0615    //
0616    // private access methods:
0617    //
0618    const BOOST_REGEX_DETAIL_NS::re_syntax_base* get_first_state()const
0619    {
0620       BOOST_REGEX_ASSERT(0 != m_pimpl.get());
0621       return m_pimpl->get_first_state();
0622    }
0623    unsigned get_restart_type()const
0624    {
0625       BOOST_REGEX_ASSERT(0 != m_pimpl.get());
0626       return m_pimpl->get_restart_type();
0627    }
0628    const unsigned char* get_map()const
0629    {
0630       BOOST_REGEX_ASSERT(0 != m_pimpl.get());
0631       return m_pimpl->get_map();
0632    }
0633    const ::boost::regex_traits_wrapper<traits>& get_traits()const
0634    {
0635       BOOST_REGEX_ASSERT(0 != m_pimpl.get());
0636       return m_pimpl->get_traits();
0637    }
0638    bool can_be_null()const
0639    {
0640       BOOST_REGEX_ASSERT(0 != m_pimpl.get());
0641       return m_pimpl->can_be_null();
0642    }
0643    const BOOST_REGEX_DETAIL_NS::regex_data<charT, traits>& get_data()const
0644    {
0645       BOOST_REGEX_ASSERT(0 != m_pimpl.get());
0646       return m_pimpl->get_data();
0647    }
0648    boost::shared_ptr<BOOST_REGEX_DETAIL_NS::named_subexpressions > get_named_subs()const
0649    {
0650       return m_pimpl;
0651    }
0652 
0653 private:
0654    shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > m_pimpl;
0655 };
0656 
0657 //
0658 // out of line members;
0659 // these are the only members that mutate the basic_regex object,
0660 // and are designed to provide the strong exception guarantee
0661 // (in the event of a throw, the state of the object remains unchanged).
0662 //
0663 template <class charT, class traits>
0664 basic_regex<charT, traits>& basic_regex<charT, traits>::do_assign(const charT* p1,
0665                         const charT* p2,
0666                         flag_type f)
0667 {
0668    shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp;
0669    if(!m_pimpl.get())
0670    {
0671       temp = shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>());
0672    }
0673    else
0674    {
0675       temp = shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> >(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>(m_pimpl->m_ptraits));
0676    }
0677    temp->assign(p1, p2, f);
0678    temp.swap(m_pimpl);
0679    return *this;
0680 }
0681 
0682 template <class charT, class traits>
0683 typename basic_regex<charT, traits>::locale_type BOOST_REGEX_CALL basic_regex<charT, traits>::imbue(locale_type l)
0684 { 
0685    shared_ptr<BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits> > temp(new BOOST_REGEX_DETAIL_NS::basic_regex_implementation<charT, traits>());
0686    locale_type result = temp->imbue(l);
0687    temp.swap(m_pimpl);
0688    return result;
0689 }
0690 
0691 //
0692 // non-members:
0693 //
0694 template <class charT, class traits>
0695 void swap(basic_regex<charT, traits>& e1, basic_regex<charT, traits>& e2)
0696 {
0697    e1.swap(e2);
0698 }
0699 
0700 #ifndef BOOST_NO_STD_LOCALE
0701 template <class charT, class traits, class traits2>
0702 std::basic_ostream<charT, traits>& 
0703    operator << (std::basic_ostream<charT, traits>& os, 
0704                 const basic_regex<charT, traits2>& e)
0705 {
0706    return (os << e.str());
0707 }
0708 #else
0709 template <class traits>
0710 std::ostream& operator << (std::ostream& os, const basic_regex<char, traits>& e)
0711 {
0712    return (os << e.str());
0713 }
0714 #endif
0715 
0716 //
0717 // class reg_expression:
0718 // this is provided for backwards compatibility only,
0719 // it is deprecated, no not use!
0720 //
0721 #ifdef BOOST_REGEX_NO_FWD
0722 template <class charT, class traits = regex_traits<charT> >
0723 #else
0724 template <class charT, class traits >
0725 #endif
0726 class reg_expression : public basic_regex<charT, traits>
0727 {
0728 public:
0729    typedef typename basic_regex<charT, traits>::flag_type flag_type;
0730    typedef typename basic_regex<charT, traits>::size_type size_type;
0731    explicit reg_expression(){}
0732    explicit reg_expression(const charT* p, flag_type f = regex_constants::normal)
0733       : basic_regex<charT, traits>(p, f){}
0734    reg_expression(const charT* p1, const charT* p2, flag_type f = regex_constants::normal)
0735       : basic_regex<charT, traits>(p1, p2, f){}
0736    reg_expression(const charT* p, size_type len, flag_type f)
0737       : basic_regex<charT, traits>(p, len, f){}
0738    reg_expression(const reg_expression& that)
0739       : basic_regex<charT, traits>(that) {}
0740    ~reg_expression(){}
0741    reg_expression& BOOST_REGEX_CALL operator=(const reg_expression& that)
0742    {
0743       return this->assign(that);
0744    }
0745 
0746 #if !defined(BOOST_NO_MEMBER_TEMPLATES)
0747    template <class ST, class SA>
0748    explicit reg_expression(const std::basic_string<charT, ST, SA>& p, flag_type f = regex_constants::normal)
0749    : basic_regex<charT, traits>(p, f)
0750    { 
0751    }
0752 
0753    template <class InputIterator>
0754    reg_expression(InputIterator arg_first, InputIterator arg_last, flag_type f = regex_constants::normal)
0755    : basic_regex<charT, traits>(arg_first, arg_last, f)
0756    {
0757    }
0758 
0759    template <class ST, class SA>
0760    reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT, ST, SA>& p)
0761    {
0762       this->assign(p);
0763       return *this;
0764    }
0765 #else
0766    explicit reg_expression(const std::basic_string<charT>& p, flag_type f = regex_constants::normal)
0767    : basic_regex<charT, traits>(p, f)
0768    { 
0769    }
0770 
0771    reg_expression& BOOST_REGEX_CALL operator=(const std::basic_string<charT>& p)
0772    {
0773       this->assign(p);
0774       return *this;
0775    }
0776 #endif
0777 
0778 };
0779 
0780 #ifdef BOOST_MSVC
0781 #pragma warning (pop)
0782 #endif
0783 
0784 } // namespace boost
0785 
0786 #ifdef BOOST_MSVC
0787 #pragma warning(push)
0788 #pragma warning(disable: 4103)
0789 #endif
0790 #ifdef BOOST_HAS_ABI_HEADERS
0791 #  include BOOST_ABI_SUFFIX
0792 #endif
0793 #ifdef BOOST_MSVC
0794 #pragma warning(pop)
0795 #endif
0796 
0797 #endif