Coverage Report

Created: 2025-12-31 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boost/boost/regex/v5/sub_match.hpp
Line
Count
Source
1
/*
2
 *
3
 * Copyright (c) 1998-2002
4
 * John Maddock
5
 *
6
 * Use, modification and distribution are subject to the 
7
 * Boost Software License, Version 1.0. (See accompanying file 
8
 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
 *
10
 */
11
12
 /*
13
  *   LOCATION:    see http://www.boost.org for most recent version.
14
  *   FILE         sub_match.cpp
15
  *   VERSION      see <boost/version.hpp>
16
  *   DESCRIPTION: Declares template class sub_match.
17
  */
18
19
#ifndef BOOST_REGEX_V5_SUB_MATCH_HPP
20
#define BOOST_REGEX_V5_SUB_MATCH_HPP
21
22
#ifndef BOOST_REGEX_AS_MODULE
23
#include <iterator>
24
#include <utility>
25
#endif
26
27
namespace boost{
28
29
BOOST_REGEX_MODULE_EXPORT template <class BidiIterator>
30
struct sub_match : public std::pair<BidiIterator, BidiIterator>
31
{
32
   typedef typename std::iterator_traits<BidiIterator>::value_type       value_type;
33
   typedef typename std::iterator_traits<BidiIterator>::difference_type  difference_type;
34
   typedef          BidiIterator                                                     iterator_type;
35
   typedef          BidiIterator                                                     iterator;
36
   typedef          BidiIterator                                                     const_iterator;
37
38
   bool matched;
39
40
106M
   sub_match() : std::pair<BidiIterator, BidiIterator>(), matched(false) {}
boost::sub_match<std::__1::__wrap_iter<char const*> >::sub_match()
Line
Count
Source
40
106M
   sub_match() : std::pair<BidiIterator, BidiIterator>(), matched(false) {}
Unexecuted instantiation: boost::sub_match<char const*>::sub_match()
Unexecuted instantiation: boost::sub_match<wchar_t const*>::sub_match()
boost::sub_match<std::__1::__wrap_iter<char*> >::sub_match()
Line
Count
Source
40
1.74k
   sub_match() : std::pair<BidiIterator, BidiIterator>(), matched(false) {}
41
21.0M
   sub_match(BidiIterator i) : std::pair<BidiIterator, BidiIterator>(i, i), matched(false) {}
boost::sub_match<std::__1::__wrap_iter<char const*> >::sub_match(std::__1::__wrap_iter<char const*>)
Line
Count
Source
41
21.0M
   sub_match(BidiIterator i) : std::pair<BidiIterator, BidiIterator>(i, i), matched(false) {}
Unexecuted instantiation: boost::sub_match<char const*>::sub_match(char const*)
Unexecuted instantiation: boost::sub_match<wchar_t const*>::sub_match(wchar_t const*)
boost::sub_match<std::__1::__wrap_iter<char*> >::sub_match(std::__1::__wrap_iter<char*>)
Line
Count
Source
41
55.9k
   sub_match(BidiIterator i) : std::pair<BidiIterator, BidiIterator>(i, i), matched(false) {}
42
   template <class T, class A>
43
   operator std::basic_string<value_type, T, A> ()const
44
   {
45
      return matched ? std::basic_string<value_type, T, A>(this->first, this->second) : std::basic_string<value_type, T, A>();
46
   }
47
   difference_type  length()const
48
54.1k
   {
49
54.1k
      difference_type n = matched ? std::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0;
50
54.1k
      return n;
51
54.1k
   }
Unexecuted instantiation: boost::sub_match<char const*>::length() const
Unexecuted instantiation: boost::sub_match<wchar_t const*>::length() const
boost::sub_match<std::__1::__wrap_iter<char*> >::length() const
Line
Count
Source
48
54.1k
   {
49
54.1k
      difference_type n = matched ? std::distance((BidiIterator)this->first, (BidiIterator)this->second) : 0;
50
54.1k
      return n;
51
54.1k
   }
Unexecuted instantiation: boost::sub_match<std::__1::__wrap_iter<char const*> >::length() const
52
   std::basic_string<value_type> str()const
53
4.81M
   {
54
4.81M
      std::basic_string<value_type> result;
55
4.81M
      if(matched)
56
4.81M
      {
57
4.81M
         std::size_t len = std::distance((BidiIterator)this->first, (BidiIterator)this->second);
58
4.81M
         result.reserve(len);
59
4.81M
         BidiIterator i = this->first;
60
70.3M
         while(i != this->second)
61
65.5M
         {
62
65.5M
            result.append(1, *i);
63
65.5M
            ++i;
64
65.5M
         }
65
4.81M
      }
66
4.81M
      return result;
67
4.81M
   }
68
   int compare(const sub_match& s)const
69
   {
70
      if(matched != s.matched)
71
         return static_cast<int>(matched) - static_cast<int>(s.matched);
72
      return str().compare(s.str());
73
   }
74
   int compare(const std::basic_string<value_type>& s)const
75
   {
76
      return str().compare(s);
77
   }
78
   int compare(const value_type* p)const
79
   {
80
      return str().compare(p);
81
   }
82
83
   bool operator==(const sub_match& that)const
84
   { return compare(that) == 0; }
85
   bool  operator !=(const sub_match& that)const
86
   { return compare(that) != 0; }
87
   bool operator<(const sub_match& that)const
88
   { return compare(that) < 0; }
89
   bool operator>(const sub_match& that)const
90
   { return compare(that) > 0; }
91
   bool operator<=(const sub_match& that)const
92
   { return compare(that) <= 0; }
93
   bool operator>=(const sub_match& that)const
94
   { return compare(that) >= 0; }
95
96
#ifdef BOOST_REGEX_MATCH_EXTRA
97
   typedef std::vector<sub_match<BidiIterator> > capture_sequence_type;
98
99
   const capture_sequence_type& captures()const
100
   {
101
      if(!m_captures) 
102
         m_captures.reset(new capture_sequence_type());
103
      return *m_captures;
104
   }
105
   //
106
   // Private implementation API: DO NOT USE!
107
   //
108
   capture_sequence_type& get_captures()const
109
   {
110
      if(!m_captures) 
111
         m_captures.reset(new capture_sequence_type());
112
      return *m_captures;
113
   }
114
115
private:
116
   mutable std::unique_ptr<capture_sequence_type> m_captures;
117
public:
118
119
#endif
120
   sub_match(const sub_match& that, bool 
121
#ifdef BOOST_REGEX_MATCH_EXTRA
122
      deep_copy
123
#endif
124
      = true
125
      ) 
126
3.10G
      : std::pair<BidiIterator, BidiIterator>(that), 
127
3.10G
        matched(that.matched) 
128
3.10G
   {
129
#ifdef BOOST_REGEX_MATCH_EXTRA
130
      if(that.m_captures)
131
         if(deep_copy)
132
            m_captures.reset(new capture_sequence_type(*(that.m_captures)));
133
#endif
134
3.10G
   }
boost::sub_match<std::__1::__wrap_iter<char const*> >::sub_match(boost::sub_match<std::__1::__wrap_iter<char const*> > const&, bool)
Line
Count
Source
126
3.10G
      : std::pair<BidiIterator, BidiIterator>(that), 
127
3.10G
        matched(that.matched) 
128
3.10G
   {
129
#ifdef BOOST_REGEX_MATCH_EXTRA
130
      if(that.m_captures)
131
         if(deep_copy)
132
            m_captures.reset(new capture_sequence_type(*(that.m_captures)));
133
#endif
134
3.10G
   }
Unexecuted instantiation: boost::sub_match<char const*>::sub_match(boost::sub_match<char const*> const&, bool)
Unexecuted instantiation: boost::sub_match<wchar_t const*>::sub_match(boost::sub_match<wchar_t const*> const&, bool)
boost::sub_match<std::__1::__wrap_iter<char*> >::sub_match(boost::sub_match<std::__1::__wrap_iter<char*> > const&, bool)
Line
Count
Source
126
64.6k
      : std::pair<BidiIterator, BidiIterator>(that), 
127
64.6k
        matched(that.matched) 
128
64.6k
   {
129
#ifdef BOOST_REGEX_MATCH_EXTRA
130
      if(that.m_captures)
131
         if(deep_copy)
132
            m_captures.reset(new capture_sequence_type(*(that.m_captures)));
133
#endif
134
64.6k
   }
135
   sub_match& operator=(const sub_match& that)
136
2.11G
   {
137
2.11G
      this->first = that.first;
138
2.11G
      this->second = that.second;
139
2.11G
      matched = that.matched;
140
#ifdef BOOST_REGEX_MATCH_EXTRA
141
      if(that.m_captures)
142
         get_captures() = *(that.m_captures);
143
#endif
144
2.11G
      return *this;
145
2.11G
   }
boost::sub_match<std::__1::__wrap_iter<char const*> >::operator=(boost::sub_match<std::__1::__wrap_iter<char const*> > const&)
Line
Count
Source
136
2.11G
   {
137
2.11G
      this->first = that.first;
138
2.11G
      this->second = that.second;
139
2.11G
      matched = that.matched;
140
#ifdef BOOST_REGEX_MATCH_EXTRA
141
      if(that.m_captures)
142
         get_captures() = *(that.m_captures);
143
#endif
144
2.11G
      return *this;
145
2.11G
   }
Unexecuted instantiation: boost::sub_match<char const*>::operator=(boost::sub_match<char const*> const&)
Unexecuted instantiation: boost::sub_match<wchar_t const*>::operator=(boost::sub_match<wchar_t const*> const&)
boost::sub_match<std::__1::__wrap_iter<char*> >::operator=(boost::sub_match<std::__1::__wrap_iter<char*> > const&)
Line
Count
Source
136
325k
   {
137
325k
      this->first = that.first;
138
325k
      this->second = that.second;
139
325k
      matched = that.matched;
140
#ifdef BOOST_REGEX_MATCH_EXTRA
141
      if(that.m_captures)
142
         get_captures() = *(that.m_captures);
143
#endif
144
325k
      return *this;
145
325k
   }
146
   //
147
   // Make this type a range, for both Boost.Range, and C++11:
148
   //
149
   BidiIterator begin()const { return this->first; }
150
   BidiIterator end()const { return this->second; }
151
};
152
153
BOOST_REGEX_MODULE_EXPORT typedef sub_match<const char*> csub_match;
154
BOOST_REGEX_MODULE_EXPORT typedef sub_match<std::string::const_iterator> ssub_match;
155
#ifndef BOOST_NO_WREGEX
156
BOOST_REGEX_MODULE_EXPORT typedef sub_match<const wchar_t*> wcsub_match;
157
BOOST_REGEX_MODULE_EXPORT typedef sub_match<std::wstring::const_iterator> wssub_match;
158
#endif
159
160
// comparison to std::basic_string<> part 1:
161
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
162
inline bool operator == (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
163
                  const sub_match<RandomAccessIterator>& m)
164
{ return s.compare(m.str()) == 0; }
165
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
166
inline bool operator != (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
167
                  const sub_match<RandomAccessIterator>& m)
168
{ return s.compare(m.str()) != 0; }
169
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
170
inline bool operator < (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
171
                 const sub_match<RandomAccessIterator>& m)
172
{ return s.compare(m.str()) < 0; }
173
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
174
inline bool operator <= (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
175
                  const sub_match<RandomAccessIterator>& m)
176
{ return s.compare(m.str()) <= 0; }
177
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
178
inline bool operator >= (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
179
                  const sub_match<RandomAccessIterator>& m)
180
{ return s.compare(m.str()) >= 0; }
181
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
182
inline bool operator > (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
183
                 const sub_match<RandomAccessIterator>& m)
184
{ return s.compare(m.str()) > 0; }
185
// comparison to std::basic_string<> part 2:
186
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
187
inline bool operator == (const sub_match<RandomAccessIterator>& m,
188
                  const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
189
{ return m.str().compare(s) == 0; }
190
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
191
inline bool operator != (const sub_match<RandomAccessIterator>& m,
192
                  const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
193
{ return m.str().compare(s) != 0; }
194
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
195
inline bool operator < (const sub_match<RandomAccessIterator>& m,
196
                  const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
197
{ return m.str().compare(s) < 0; }
198
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
199
inline bool operator > (const sub_match<RandomAccessIterator>& m,
200
                  const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
201
{ return m.str().compare(s) > 0; }
202
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
203
inline bool operator <= (const sub_match<RandomAccessIterator>& m,
204
                  const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
205
{ return m.str().compare(s) <= 0; }
206
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
207
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
208
                  const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
209
{ return m.str().compare(s) >= 0; }
210
// comparison to const charT* part 1:
211
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
212
inline bool operator == (const sub_match<RandomAccessIterator>& m,
213
                  typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
214
{ return m.str().compare(s) == 0; }
215
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
216
inline bool operator != (const sub_match<RandomAccessIterator>& m,
217
                  typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
218
{ return m.str().compare(s) != 0; }
219
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
220
inline bool operator > (const sub_match<RandomAccessIterator>& m,
221
                  typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
222
{ return m.str().compare(s) > 0; }
223
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
224
inline bool operator < (const sub_match<RandomAccessIterator>& m,
225
                  typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
226
{ return m.str().compare(s) < 0; }
227
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
228
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
229
                  typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
230
{ return m.str().compare(s) >= 0; }
231
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
232
inline bool operator <= (const sub_match<RandomAccessIterator>& m,
233
                  typename std::iterator_traits<RandomAccessIterator>::value_type const* s)
234
{ return m.str().compare(s) <= 0; }
235
// comparison to const charT* part 2:
236
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
237
inline bool operator == (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
238
                  const sub_match<RandomAccessIterator>& m)
239
{ return m.str().compare(s) == 0; }
240
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
241
inline bool operator != (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
242
                  const sub_match<RandomAccessIterator>& m)
243
{ return m.str().compare(s) != 0; }
244
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
245
inline bool operator < (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
246
                  const sub_match<RandomAccessIterator>& m)
247
{ return m.str().compare(s) > 0; }
248
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
249
inline bool operator > (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
250
                  const sub_match<RandomAccessIterator>& m)
251
{ return m.str().compare(s) < 0; }
252
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
253
inline bool operator <= (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
254
                  const sub_match<RandomAccessIterator>& m)
255
{ return m.str().compare(s) >= 0; }
256
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
257
inline bool operator >= (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
258
                  const sub_match<RandomAccessIterator>& m)
259
{ return m.str().compare(s) <= 0; }
260
261
// comparison to const charT& part 1:
262
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
263
inline bool operator == (const sub_match<RandomAccessIterator>& m,
264
                  typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
265
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
266
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
267
inline bool operator != (const sub_match<RandomAccessIterator>& m,
268
                  typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
269
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
270
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
271
inline bool operator > (const sub_match<RandomAccessIterator>& m,
272
                  typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
273
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
274
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
275
inline bool operator < (const sub_match<RandomAccessIterator>& m,
276
                  typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
277
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
278
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
279
inline bool operator >= (const sub_match<RandomAccessIterator>& m,
280
                  typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
281
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
282
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
283
inline bool operator <= (const sub_match<RandomAccessIterator>& m,
284
                  typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
285
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
286
// comparison to const charT* part 2:
287
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
288
inline bool operator == (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
289
                  const sub_match<RandomAccessIterator>& m)
290
{ return m.str().compare(0, m.length(), &s, 1) == 0; }
291
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
292
inline bool operator != (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
293
                  const sub_match<RandomAccessIterator>& m)
294
{ return m.str().compare(0, m.length(), &s, 1) != 0; }
295
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
296
inline bool operator < (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
297
                  const sub_match<RandomAccessIterator>& m)
298
{ return m.str().compare(0, m.length(), &s, 1) > 0; }
299
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
300
inline bool operator > (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
301
                  const sub_match<RandomAccessIterator>& m)
302
{ return m.str().compare(0, m.length(), &s, 1) < 0; }
303
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
304
inline bool operator <= (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
305
                  const sub_match<RandomAccessIterator>& m)
306
{ return m.str().compare(0, m.length(), &s, 1) >= 0; }
307
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
308
inline bool operator >= (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
309
                  const sub_match<RandomAccessIterator>& m)
310
{ return m.str().compare(0, m.length(), &s, 1) <= 0; }
311
312
// addition operators:
313
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
314
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> 
315
operator + (const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
316
                  const sub_match<RandomAccessIterator>& m)
317
{
318
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
319
   result.reserve(s.size() + m.length() + 1);
320
   return result.append(s).append(m.first, m.second);
321
}
322
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator, class traits, class Allocator>
323
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> 
324
operator + (const sub_match<RandomAccessIterator>& m,
325
            const std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s)
326
{
327
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type, traits, Allocator> result;
328
   result.reserve(s.size() + m.length() + 1);
329
   return result.append(m.first, m.second).append(s);
330
}
331
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
332
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> 
333
operator + (typename std::iterator_traits<RandomAccessIterator>::value_type const* s,
334
                  const sub_match<RandomAccessIterator>& m)
335
{
336
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
337
   result.reserve(std::char_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
338
   return result.append(s).append(m.first, m.second);
339
}
340
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
341
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> 
342
operator + (const sub_match<RandomAccessIterator>& m,
343
            typename std::iterator_traits<RandomAccessIterator>::value_type const * s)
344
{
345
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
346
   result.reserve(std::char_traits<typename std::iterator_traits<RandomAccessIterator>::value_type>::length(s) + m.length() + 1);
347
   return result.append(m.first, m.second).append(s);
348
}
349
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
350
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> 
351
operator + (typename std::iterator_traits<RandomAccessIterator>::value_type const& s,
352
                  const sub_match<RandomAccessIterator>& m)
353
{
354
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
355
   result.reserve(m.length() + 2);
356
   return result.append(1, s).append(m.first, m.second);
357
}
358
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
359
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> 
360
operator + (const sub_match<RandomAccessIterator>& m,
361
            typename std::iterator_traits<RandomAccessIterator>::value_type const& s)
362
{
363
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
364
   result.reserve(m.length() + 2);
365
   return result.append(m.first, m.second).append(1, s);
366
}
367
BOOST_REGEX_MODULE_EXPORT template <class RandomAccessIterator>
368
inline std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> 
369
operator + (const sub_match<RandomAccessIterator>& m1,
370
            const sub_match<RandomAccessIterator>& m2)
371
{
372
   std::basic_string<typename std::iterator_traits<RandomAccessIterator>::value_type> result;
373
   result.reserve(m1.length() + m2.length() + 1);
374
   return result.append(m1.first, m1.second).append(m2.first, m2.second);
375
}
376
BOOST_REGEX_MODULE_EXPORT template <class charT, class traits, class RandomAccessIterator>
377
std::basic_ostream<charT, traits>&
378
   operator << (std::basic_ostream<charT, traits>& os,
379
                const sub_match<RandomAccessIterator>& s)
380
{
381
   return (os << s.str());
382
}
383
384
} // namespace boost
385
386
#endif
387