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)
13 * LOCATION: see http://www.boost.org for most recent version.
15 * VERSION see <boost/version.hpp>
16 * DESCRIPTION: Declares regular expression concepts.
19 #ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED
20 #define BOOST_REGEX_CONCEPTS_HPP_INCLUDED
22 #include <boost/concept_archetype.hpp>
23 #include <boost/concept_check.hpp>
24 #include <boost/type_traits/is_enum.hpp>
25 #include <boost/type_traits/is_base_and_derived.hpp>
26 #include <boost/static_assert.hpp>
27 #ifndef BOOST_TEST_TR1_REGEX
28 #include <boost/regex.hpp>
38 // this can be either an integer type, an enum, or a std::bitset,
39 // we use the latter as the architype as it offers the "strictest"
40 // of the possible interfaces:
42 typedef std::bitset<512> bitmask_archetype;
45 // A strict model for the character type interface.
49 // default constructable:
51 // copy constructable / assignable:
52 char_architype(const char_architype&);
53 char_architype& operator=(const char_architype&);
54 // constructable from an integral value:
55 char_architype(unsigned long val);
57 bool operator==(const char_architype&)const;
58 bool operator!=(const char_architype&)const;
59 bool operator<(const char_architype&)const;
60 bool operator<=(const char_architype&)const;
61 bool operator>=(const char_architype&)const;
62 bool operator>(const char_architype&)const;
63 // conversion to integral type:
67 // char_architype can not be used with basic_string:
71 template<> struct char_traits<boost::char_architype>
73 // The intent is that this template is not instantiated,
74 // but this typedef gives us a chance of compilation in
76 typedef boost::char_architype char_type;
81 // regex_traits_architype:
82 // A strict interpretation of the regular expression traits class requirements.
84 template <class charT>
85 struct regex_traits_architype
88 regex_traits_architype();
89 typedef charT char_type;
90 // typedef std::size_t size_type;
91 typedef std::vector<char_type> string_type;
92 typedef copy_constructible_archetype<assignable_archetype<> > locale_type;
93 typedef bitmask_archetype char_class_type;
95 static std::size_t length(const char_type* ) { return 0; }
97 charT translate(charT ) const { return charT(); }
98 charT translate_nocase(charT ) const { return static_object<charT>::get(); }
100 template <class ForwardIterator>
101 string_type transform(ForwardIterator , ForwardIterator ) const
102 { return static_object<string_type>::get(); }
103 template <class ForwardIterator>
104 string_type transform_primary(ForwardIterator , ForwardIterator ) const
105 { return static_object<string_type>::get(); }
107 template <class ForwardIterator>
108 char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const
109 { return static_object<char_class_type>::get(); }
110 template <class ForwardIterator>
111 string_type lookup_collatename(ForwardIterator , ForwardIterator ) const
112 { return static_object<string_type>::get(); }
114 bool isctype(charT, char_class_type) const
116 int value(charT, int) const
119 locale_type imbue(locale_type l)
121 locale_type getloc()const
122 { return static_object<locale_type>::get(); }
125 // this type is not copyable:
126 regex_traits_architype(const regex_traits_architype&);
127 regex_traits_architype& operator=(const regex_traits_architype&);
131 // alter this to std::tr1, to test a std implementation:
133 #ifndef BOOST_TEST_TR1_REGEX
134 namespace global_regex_namespace = ::boost;
136 namespace global_regex_namespace = ::std::tr1;
139 template <class Bitmask>
140 struct BitmaskConcept
144 function_requires<CopyConstructibleConcept<Bitmask> >();
145 function_requires<AssignableConcept<Bitmask> >();
147 m_mask1 = m_mask2 | m_mask3;
148 m_mask1 = m_mask2 & m_mask3;
149 m_mask1 = m_mask2 ^ m_mask3;
157 Bitmask m_mask1, m_mask2, m_mask3;
160 template <class traits>
161 struct RegexTraitsConcept
163 RegexTraitsConcept();
164 // required typedefs:
165 typedef typename traits::char_type char_type;
166 // typedef typename traits::size_type size_type;
167 typedef typename traits::string_type string_type;
168 typedef typename traits::locale_type locale_type;
169 typedef typename traits::char_class_type char_class_type;
173 //function_requires<UnsignedIntegerConcept<size_type> >();
174 function_requires<RandomAccessContainerConcept<string_type> >();
175 function_requires<DefaultConstructibleConcept<locale_type> >();
176 function_requires<CopyConstructibleConcept<locale_type> >();
177 function_requires<AssignableConcept<locale_type> >();
178 function_requires<BitmaskConcept<char_class_type> >();
180 std::size_t n = traits::length(m_pointer);
181 ignore_unused_variable_warning(n);
183 char_type c = m_ctraits.translate(m_char);
184 ignore_unused_variable_warning(c);
185 c = m_ctraits.translate_nocase(m_char);
187 //string_type::foobar bar;
188 string_type s1 = m_ctraits.transform(m_pointer, m_pointer);
189 ignore_unused_variable_warning(s1);
191 string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer);
192 ignore_unused_variable_warning(s2);
194 char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer);
195 ignore_unused_variable_warning(cc);
197 string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer);
198 ignore_unused_variable_warning(s3);
200 bool b = m_ctraits.isctype(m_char, cc);
201 ignore_unused_variable_warning(b);
203 int v = m_ctraits.value(m_char, 16);
204 ignore_unused_variable_warning(v);
206 locale_type l(m_ctraits.getloc());
208 ignore_unused_variable_warning(l);
211 const traits m_ctraits;
212 const char_type* m_pointer;
215 RegexTraitsConcept& operator=(RegexTraitsConcept&);
219 // helper class to compute what traits class a regular expression type is using:
221 template <class Regex>
222 struct regex_traits_computer;
224 template <class charT, class traits>
225 struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> >
231 // BaseRegexConcept does not test anything dependent on basic_string,
232 // in case our charT does not have an associated char_traits:
234 template <class Regex>
235 struct BaseRegexConcept
237 typedef typename Regex::value_type value_type;
238 //typedef typename Regex::size_type size_type;
239 typedef typename Regex::flag_type flag_type;
240 typedef typename Regex::locale_type locale_type;
241 typedef input_iterator_archetype<value_type> input_iterator_type;
243 // derived test types:
244 typedef const value_type* pointer_type;
245 typedef bidirectional_iterator_archetype<value_type> BidiIterator;
246 typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
247 typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
248 typedef output_iterator_archetype<value_type> OutIterator;
249 typedef typename regex_traits_computer<Regex>::type traits_type;
250 typedef global_regex_namespace::regex_iterator<BidiIterator, value_type, traits_type> regex_iterator_type;
251 typedef global_regex_namespace::regex_token_iterator<BidiIterator, value_type, traits_type> regex_token_iterator_type;
253 void global_constraints()
256 // test non-template components:
258 function_requires<BitmaskConcept<global_regex_namespace::regex_constants::syntax_option_type> >();
259 global_regex_namespace::regex_constants::syntax_option_type opts
260 = global_regex_namespace::regex_constants::icase
261 | global_regex_namespace::regex_constants::nosubs
262 | global_regex_namespace::regex_constants::optimize
263 | global_regex_namespace::regex_constants::collate
264 | global_regex_namespace::regex_constants::ECMAScript
265 | global_regex_namespace::regex_constants::basic
266 | global_regex_namespace::regex_constants::extended
267 | global_regex_namespace::regex_constants::awk
268 | global_regex_namespace::regex_constants::grep
269 | global_regex_namespace::regex_constants::egrep;
270 ignore_unused_variable_warning(opts);
272 function_requires<BitmaskConcept<global_regex_namespace::regex_constants::match_flag_type> >();
273 global_regex_namespace::regex_constants::match_flag_type mopts
274 = global_regex_namespace::regex_constants::match_default
275 | global_regex_namespace::regex_constants::match_not_bol
276 | global_regex_namespace::regex_constants::match_not_eol
277 | global_regex_namespace::regex_constants::match_not_bow
278 | global_regex_namespace::regex_constants::match_not_eow
279 | global_regex_namespace::regex_constants::match_any
280 | global_regex_namespace::regex_constants::match_not_null
281 | global_regex_namespace::regex_constants::match_continuous
282 | global_regex_namespace::regex_constants::match_prev_avail
283 | global_regex_namespace::regex_constants::format_default
284 | global_regex_namespace::regex_constants::format_sed
285 | global_regex_namespace::regex_constants::format_no_copy
286 | global_regex_namespace::regex_constants::format_first_only;
287 ignore_unused_variable_warning(mopts);
289 BOOST_STATIC_ASSERT((::boost::is_enum<global_regex_namespace::regex_constants::error_type>::value));
290 global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate;
291 ignore_unused_variable_warning(e1);
292 e1 = global_regex_namespace::regex_constants::error_ctype;
293 ignore_unused_variable_warning(e1);
294 e1 = global_regex_namespace::regex_constants::error_escape;
295 ignore_unused_variable_warning(e1);
296 e1 = global_regex_namespace::regex_constants::error_backref;
297 ignore_unused_variable_warning(e1);
298 e1 = global_regex_namespace::regex_constants::error_brack;
299 ignore_unused_variable_warning(e1);
300 e1 = global_regex_namespace::regex_constants::error_paren;
301 ignore_unused_variable_warning(e1);
302 e1 = global_regex_namespace::regex_constants::error_brace;
303 ignore_unused_variable_warning(e1);
304 e1 = global_regex_namespace::regex_constants::error_badbrace;
305 ignore_unused_variable_warning(e1);
306 e1 = global_regex_namespace::regex_constants::error_range;
307 ignore_unused_variable_warning(e1);
308 e1 = global_regex_namespace::regex_constants::error_space;
309 ignore_unused_variable_warning(e1);
310 e1 = global_regex_namespace::regex_constants::error_badrepeat;
311 ignore_unused_variable_warning(e1);
312 e1 = global_regex_namespace::regex_constants::error_complexity;
313 ignore_unused_variable_warning(e1);
314 e1 = global_regex_namespace::regex_constants::error_stack;
315 ignore_unused_variable_warning(e1);
317 BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::runtime_error, global_regex_namespace::regex_error>::value ));
318 const global_regex_namespace::regex_error except(e1);
321 typedef typename Regex::value_type value_type;
322 function_requires< RegexTraitsConcept<global_regex_namespace::regex_traits<char> > >();
323 function_requires< BaseRegexConcept<global_regex_namespace::basic_regex<char> > >();
327 global_constraints();
329 BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value));
341 ignore_unused_variable_warning(opts);
343 function_requires<DefaultConstructibleConcept<Regex> >();
344 function_requires<CopyConstructibleConcept<Regex> >();
346 // Regex constructors:
348 ignore_unused_variable_warning(e1);
349 Regex e2(m_pointer, m_flags);
350 ignore_unused_variable_warning(e2);
351 Regex e3(m_pointer, m_size, m_flags);
352 ignore_unused_variable_warning(e3);
354 ignore_unused_variable_warning(e4);
355 Regex e5(in1, in2, m_flags);
356 ignore_unused_variable_warning(e5);
364 e.assign(m_pointer, m_flags);
365 e.assign(m_pointer, m_size, m_flags);
367 e.assign(in1, in2, m_flags);
371 unsigned i = ce.mark_count();
372 ignore_unused_variable_warning(i);
373 m_flags = ce.flags();
374 e.imbue(ce.getloc());
377 global_regex_namespace::swap(e, e1);
380 BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::pair<BidiIterator, BidiIterator>, sub_match_type>::value));
381 typedef typename sub_match_type::value_type sub_value_type;
382 typedef typename sub_match_type::difference_type sub_diff_type;
383 typedef typename sub_match_type::iterator sub_iter_type;
384 BOOST_STATIC_ASSERT((::boost::is_same<sub_value_type, value_type>::value));
385 BOOST_STATIC_ASSERT((::boost::is_same<sub_iter_type, BidiIterator>::value));
386 bool b = m_sub.matched;
387 ignore_unused_variable_warning(b);
388 BidiIterator bi = m_sub.first;
389 ignore_unused_variable_warning(bi);
391 ignore_unused_variable_warning(bi);
392 sub_diff_type diff = m_sub.length();
393 ignore_unused_variable_warning(diff);
394 // match_results tests:
395 typedef typename match_results_type::value_type mr_value_type;
396 typedef typename match_results_type::const_reference mr_const_reference;
397 typedef typename match_results_type::reference mr_reference;
398 typedef typename match_results_type::const_iterator mr_const_iterator;
399 typedef typename match_results_type::iterator mr_iterator;
400 typedef typename match_results_type::difference_type mr_difference_type;
401 typedef typename match_results_type::size_type mr_size_type;
402 typedef typename match_results_type::allocator_type mr_allocator_type;
403 typedef typename match_results_type::char_type mr_char_type;
404 typedef typename match_results_type::string_type mr_string_type;
406 match_results_type m1;
407 mr_allocator_type at;
408 match_results_type m2(at);
409 match_results_type m3(m1);
414 mr_size_type mrs = m_cresults.size();
415 ignore_unused_variable_warning(mrs);
416 mrs = m_cresults.max_size();
417 ignore_unused_variable_warning(mrs);
418 b = m_cresults.empty();
419 ignore_unused_variable_warning(b);
420 mr_difference_type mrd = m_cresults.length();
421 ignore_unused_variable_warning(mrd);
422 mrd = m_cresults.length(ival);
423 ignore_unused_variable_warning(mrd);
424 mrd = m_cresults.position();
425 ignore_unused_variable_warning(mrd);
426 mrd = m_cresults.position(mrs);
427 ignore_unused_variable_warning(mrd);
429 mr_const_reference mrcr = m_cresults[ival];
430 ignore_unused_variable_warning(mrcr);
431 mr_const_reference mrcr2 = m_cresults.prefix();
432 ignore_unused_variable_warning(mrcr2);
433 mr_const_reference mrcr3 = m_cresults.suffix();
434 ignore_unused_variable_warning(mrcr3);
435 mr_const_iterator mrci = m_cresults.begin();
436 ignore_unused_variable_warning(mrci);
437 mrci = m_cresults.end();
438 ignore_unused_variable_warning(mrci);
440 mr_allocator_type at2 = m_cresults.get_allocator();
441 m_results.swap(m_results);
442 global_regex_namespace::swap(m_results, m_results);
445 b = global_regex_namespace::regex_match(m_in, m_in, m_results, e);
446 ignore_unused_variable_warning(b);
447 b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft);
448 ignore_unused_variable_warning(b);
449 b = global_regex_namespace::regex_match(m_in, m_in, e);
450 ignore_unused_variable_warning(b);
451 b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft);
452 ignore_unused_variable_warning(b);
453 b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e);
454 ignore_unused_variable_warning(b);
455 b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft);
456 ignore_unused_variable_warning(b);
457 b = global_regex_namespace::regex_match(m_pointer, e);
458 ignore_unused_variable_warning(b);
459 b = global_regex_namespace::regex_match(m_pointer, e, m_mft);
460 ignore_unused_variable_warning(b);
462 b = global_regex_namespace::regex_search(m_in, m_in, m_results, e);
463 ignore_unused_variable_warning(b);
464 b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft);
465 ignore_unused_variable_warning(b);
466 b = global_regex_namespace::regex_search(m_in, m_in, e);
467 ignore_unused_variable_warning(b);
468 b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft);
469 ignore_unused_variable_warning(b);
470 b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e);
471 ignore_unused_variable_warning(b);
472 b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft);
473 ignore_unused_variable_warning(b);
474 b = global_regex_namespace::regex_search(m_pointer, e);
475 ignore_unused_variable_warning(b);
476 b = global_regex_namespace::regex_search(m_pointer, e, m_mft);
477 ignore_unused_variable_warning(b);
480 typedef typename regex_iterator_type::regex_type rit_regex_type;
481 typedef typename regex_iterator_type::value_type rit_value_type;
482 typedef typename regex_iterator_type::difference_type rit_difference_type;
483 typedef typename regex_iterator_type::pointer rit_pointer;
484 typedef typename regex_iterator_type::reference rit_reference;
485 typedef typename regex_iterator_type::iterator_category rit_iterator_category;
486 BOOST_STATIC_ASSERT((::boost::is_same<rit_regex_type, Regex>::value));
487 BOOST_STATIC_ASSERT((::boost::is_same<rit_value_type, match_results_type>::value));
488 BOOST_STATIC_ASSERT((::boost::is_same<rit_difference_type, std::ptrdiff_t>::value));
489 BOOST_STATIC_ASSERT((::boost::is_same<rit_pointer, const match_results_type*>::value));
490 BOOST_STATIC_ASSERT((::boost::is_same<rit_reference, const match_results_type&>::value));
491 BOOST_STATIC_ASSERT((::boost::is_convertible<rit_iterator_category*, std::forward_iterator_tag*>::value));
492 // this takes care of most of the checks needed:
493 function_requires<ForwardIteratorConcept<regex_iterator_type> >();
494 regex_iterator_type iter1(m_in, m_in, e);
495 ignore_unused_variable_warning(iter1);
496 regex_iterator_type iter2(m_in, m_in, e, m_mft);
497 ignore_unused_variable_warning(iter2);
499 // regex_token_iterator:
500 typedef typename regex_token_iterator_type::regex_type rtit_regex_type;
501 typedef typename regex_token_iterator_type::value_type rtit_value_type;
502 typedef typename regex_token_iterator_type::difference_type rtit_difference_type;
503 typedef typename regex_token_iterator_type::pointer rtit_pointer;
504 typedef typename regex_token_iterator_type::reference rtit_reference;
505 typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category;
506 BOOST_STATIC_ASSERT((::boost::is_same<rtit_regex_type, Regex>::value));
507 BOOST_STATIC_ASSERT((::boost::is_same<rtit_value_type, sub_match_type>::value));
508 BOOST_STATIC_ASSERT((::boost::is_same<rtit_difference_type, std::ptrdiff_t>::value));
509 BOOST_STATIC_ASSERT((::boost::is_same<rtit_pointer, const sub_match_type*>::value));
510 BOOST_STATIC_ASSERT((::boost::is_same<rtit_reference, const sub_match_type&>::value));
511 BOOST_STATIC_ASSERT((::boost::is_convertible<rtit_iterator_category*, std::forward_iterator_tag*>::value));
512 // this takes care of most of the checks needed:
513 function_requires<ForwardIteratorConcept<regex_token_iterator_type> >();
514 regex_token_iterator_type ti1(m_in, m_in, e);
515 ignore_unused_variable_warning(ti1);
516 regex_token_iterator_type ti2(m_in, m_in, e, 0);
517 ignore_unused_variable_warning(ti2);
518 regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft);
519 ignore_unused_variable_warning(ti3);
520 std::vector<int> subs;
521 regex_token_iterator_type ti4(m_in, m_in, e, subs);
522 ignore_unused_variable_warning(ti4);
523 regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft);
524 ignore_unused_variable_warning(ti5);
525 static const int i_array[3] = { 1, 2, 3, };
526 regex_token_iterator_type ti6(m_in, m_in, e, i_array);
527 ignore_unused_variable_warning(ti6);
528 regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft);
529 ignore_unused_variable_warning(ti7);
532 pointer_type m_pointer;
535 input_iterator_type in1, in2;
536 const sub_match_type m_sub;
537 const value_type m_char;
538 match_results_type m_results;
539 const match_results_type m_cresults;
542 global_regex_namespace::regex_constants::match_flag_type m_mft;
543 global_regex_namespace::match_results<pointer_type> m_pmatch;
546 BaseRegexConcept(const BaseRegexConcept&);
547 BaseRegexConcept& operator=(const BaseRegexConcept&);
552 // Test every interface in the std:
554 template <class Regex>
557 typedef typename Regex::value_type value_type;
558 //typedef typename Regex::size_type size_type;
559 typedef typename Regex::flag_type flag_type;
560 typedef typename Regex::locale_type locale_type;
562 // derived test types:
563 typedef const value_type* pointer_type;
564 typedef std::basic_string<value_type> string_type;
565 typedef boost::bidirectional_iterator_archetype<value_type> BidiIterator;
566 typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
567 typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
568 typedef output_iterator_archetype<value_type> OutIterator;
573 function_requires<BaseRegexConcept<Regex> >();
574 // string based construct:
576 ignore_unused_variable_warning(e1);
577 Regex e2(m_string, m_flags);
578 ignore_unused_variable_warning(e2);
584 e.assign(m_string, m_flags);
587 string_type s(m_sub);
588 ignore_unused_variable_warning(s);
590 ignore_unused_variable_warning(s);
591 int i = m_sub.compare(m_string);
592 ignore_unused_variable_warning(i);
594 int i2 = m_sub.compare(m_sub);
595 ignore_unused_variable_warning(i2);
596 i2 = m_sub.compare(m_pointer);
597 ignore_unused_variable_warning(i2);
599 bool b = m_sub == m_sub;
600 ignore_unused_variable_warning(b);
602 ignore_unused_variable_warning(b);
604 ignore_unused_variable_warning(b);
606 ignore_unused_variable_warning(b);
608 ignore_unused_variable_warning(b);
610 ignore_unused_variable_warning(b);
612 b = m_sub == m_pointer;
613 ignore_unused_variable_warning(b);
614 b = m_sub != m_pointer;
615 ignore_unused_variable_warning(b);
616 b = m_sub <= m_pointer;
617 ignore_unused_variable_warning(b);
618 b = m_sub <= m_pointer;
619 ignore_unused_variable_warning(b);
620 b = m_sub > m_pointer;
621 ignore_unused_variable_warning(b);
622 b = m_sub >= m_pointer;
623 ignore_unused_variable_warning(b);
625 b = m_pointer == m_sub;
626 ignore_unused_variable_warning(b);
627 b = m_pointer != m_sub;
628 ignore_unused_variable_warning(b);
629 b = m_pointer <= m_sub;
630 ignore_unused_variable_warning(b);
631 b = m_pointer <= m_sub;
632 ignore_unused_variable_warning(b);
633 b = m_pointer > m_sub;
634 ignore_unused_variable_warning(b);
635 b = m_pointer >= m_sub;
636 ignore_unused_variable_warning(b);
639 ignore_unused_variable_warning(b);
641 ignore_unused_variable_warning(b);
643 ignore_unused_variable_warning(b);
645 ignore_unused_variable_warning(b);
647 ignore_unused_variable_warning(b);
649 ignore_unused_variable_warning(b);
652 ignore_unused_variable_warning(b);
654 ignore_unused_variable_warning(b);
656 ignore_unused_variable_warning(b);
658 ignore_unused_variable_warning(b);
660 ignore_unused_variable_warning(b);
662 ignore_unused_variable_warning(b);
664 b = m_sub == m_string;
665 ignore_unused_variable_warning(b);
666 b = m_sub != m_string;
667 ignore_unused_variable_warning(b);
668 b = m_sub <= m_string;
669 ignore_unused_variable_warning(b);
670 b = m_sub <= m_string;
671 ignore_unused_variable_warning(b);
672 b = m_sub > m_string;
673 ignore_unused_variable_warning(b);
674 b = m_sub >= m_string;
675 ignore_unused_variable_warning(b);
677 b = m_string == m_sub;
678 ignore_unused_variable_warning(b);
679 b = m_string != m_sub;
680 ignore_unused_variable_warning(b);
681 b = m_string <= m_sub;
682 ignore_unused_variable_warning(b);
683 b = m_string <= m_sub;
684 ignore_unused_variable_warning(b);
685 b = m_string > m_sub;
686 ignore_unused_variable_warning(b);
687 b = m_string >= m_sub;
688 ignore_unused_variable_warning(b);
691 m_string = m_results.str();
692 ignore_unused_variable_warning(m_string);
693 m_string = m_results.str(0);
694 ignore_unused_variable_warning(m_string);
695 m_out = m_cresults.format(m_out, m_string);
696 m_out = m_cresults.format(m_out, m_string, m_mft);
697 m_string = m_cresults.format(m_string);
698 ignore_unused_variable_warning(m_string);
699 m_string = m_cresults.format(m_string, m_mft);
700 ignore_unused_variable_warning(m_string);
703 b = global_regex_namespace::regex_match(m_string, m_smatch, e);
704 ignore_unused_variable_warning(b);
705 b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft);
706 ignore_unused_variable_warning(b);
707 b = global_regex_namespace::regex_match(m_string, e);
708 ignore_unused_variable_warning(b);
709 b = global_regex_namespace::regex_match(m_string, e, m_mft);
710 ignore_unused_variable_warning(b);
713 b = global_regex_namespace::regex_search(m_string, m_smatch, e);
714 ignore_unused_variable_warning(b);
715 b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft);
716 ignore_unused_variable_warning(b);
717 b = global_regex_namespace::regex_search(m_string, e);
718 ignore_unused_variable_warning(b);
719 b = global_regex_namespace::regex_search(m_string, e, m_mft);
720 ignore_unused_variable_warning(b);
723 m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft);
724 m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string);
725 m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft);
726 ignore_unused_variable_warning(m_string);
727 m_string = global_regex_namespace::regex_replace(m_string, e, m_string);
728 ignore_unused_variable_warning(m_string);
733 string_type m_string;
734 const sub_match_type m_sub;
735 match_results_type m_results;
736 pointer_type m_pointer;
738 const match_results_type m_cresults;
741 global_regex_namespace::regex_constants::match_flag_type m_mft;
742 global_regex_namespace::match_results<typename string_type::const_iterator> m_smatch;
745 RegexConcept(const RegexConcept&);
746 RegexConcept& operator=(const RegexConcept&);
749 #ifndef BOOST_REGEX_TEST_STD
754 typedef typename M::char_type char_type;
755 const char_type* operator()(const M&)
757 static const char_type c = static_cast<char_type>(0);
764 typedef typename M::char_type char_type;
765 std::vector<char_type> operator()(const M&)
767 static const std::vector<char_type> c;
775 O operator()(const M& /*m*/, O i)
784 O operator()(const M& /*m*/, O i, regex_constants::match_flag_type)
791 // BoostRegexConcept:
792 // Test every interface in the Boost implementation:
794 template <class Regex>
795 struct BoostRegexConcept
797 typedef typename Regex::value_type value_type;
798 typedef typename Regex::size_type size_type;
799 typedef typename Regex::flag_type flag_type;
800 typedef typename Regex::locale_type locale_type;
802 // derived test types:
803 typedef const value_type* pointer_type;
804 typedef std::basic_string<value_type> string_type;
805 typedef typename Regex::const_iterator const_iterator;
806 typedef bidirectional_iterator_archetype<value_type> BidiIterator;
807 typedef output_iterator_archetype<value_type> OutputIterator;
808 typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
809 typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
813 global_regex_namespace::regex_constants::match_flag_type mopts
814 = global_regex_namespace::regex_constants::match_default
815 | global_regex_namespace::regex_constants::match_not_bol
816 | global_regex_namespace::regex_constants::match_not_eol
817 | global_regex_namespace::regex_constants::match_not_bow
818 | global_regex_namespace::regex_constants::match_not_eow
819 | global_regex_namespace::regex_constants::match_any
820 | global_regex_namespace::regex_constants::match_not_null
821 | global_regex_namespace::regex_constants::match_continuous
822 | global_regex_namespace::regex_constants::match_partial
823 | global_regex_namespace::regex_constants::match_prev_avail
824 | global_regex_namespace::regex_constants::format_default
825 | global_regex_namespace::regex_constants::format_sed
826 | global_regex_namespace::regex_constants::format_perl
827 | global_regex_namespace::regex_constants::format_no_copy
828 | global_regex_namespace::regex_constants::format_first_only;
832 function_requires<RegexConcept<Regex> >();
833 const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate);
834 std::ptrdiff_t pt = except.position();
835 ignore_unused_variable_warning(pt);
837 #ifndef BOOST_NO_STD_LOCALE
840 unsigned i = ce.error_code();
841 ignore_unused_variable_warning(i);
842 pointer_type p = ce.expression();
843 ignore_unused_variable_warning(p);
844 int i2 = ce.compare(ce2);
845 ignore_unused_variable_warning(i2);
847 ignore_unused_variable_warning(b);
849 ignore_unused_variable_warning(b);
851 ignore_unused_variable_warning(b);
853 ignore_unused_variable_warning(b);
855 ignore_unused_variable_warning(b);
857 ignore_unused_variable_warning(b);
859 ignore_unused_variable_warning(b);
861 ignore_unused_variable_warning(i);
862 size_type s = ce.max_size();
863 ignore_unused_variable_warning(s);
865 ignore_unused_variable_warning(s);
866 const_iterator pi = ce.begin();
867 ignore_unused_variable_warning(pi);
869 ignore_unused_variable_warning(pi);
870 string_type s2 = ce.str();
871 ignore_unused_variable_warning(s2);
873 m_string = m_sub + m_sub;
874 ignore_unused_variable_warning(m_string);
875 m_string = m_sub + m_pointer;
876 ignore_unused_variable_warning(m_string);
877 m_string = m_pointer + m_sub;
878 ignore_unused_variable_warning(m_string);
879 m_string = m_sub + m_string;
880 ignore_unused_variable_warning(m_string);
881 m_string = m_string + m_sub;
882 ignore_unused_variable_warning(m_string);
883 m_string = m_sub + m_char;
884 ignore_unused_variable_warning(m_string);
885 m_string = m_char + m_sub;
886 ignore_unused_variable_warning(m_string);
888 // Named sub-expressions:
889 m_sub = m_cresults[&m_char];
890 ignore_unused_variable_warning(m_sub);
891 m_sub = m_cresults[m_string];
892 ignore_unused_variable_warning(m_sub);
893 m_sub = m_cresults[""];
894 ignore_unused_variable_warning(m_sub);
895 m_sub = m_cresults[std::string("")];
896 ignore_unused_variable_warning(m_sub);
897 m_string = m_cresults.str(&m_char);
898 ignore_unused_variable_warning(m_string);
899 m_string = m_cresults.str(m_string);
900 ignore_unused_variable_warning(m_string);
901 m_string = m_cresults.str("");
902 ignore_unused_variable_warning(m_string);
903 m_string = m_cresults.str(std::string(""));
904 ignore_unused_variable_warning(m_string);
906 typename match_results_type::difference_type diff;
907 diff = m_cresults.length(&m_char);
908 ignore_unused_variable_warning(diff);
909 diff = m_cresults.length(m_string);
910 ignore_unused_variable_warning(diff);
911 diff = m_cresults.length("");
912 ignore_unused_variable_warning(diff);
913 diff = m_cresults.length(std::string(""));
914 ignore_unused_variable_warning(diff);
915 diff = m_cresults.position(&m_char);
916 ignore_unused_variable_warning(diff);
917 diff = m_cresults.position(m_string);
918 ignore_unused_variable_warning(diff);
919 diff = m_cresults.position("");
920 ignore_unused_variable_warning(diff);
921 diff = m_cresults.position(std::string(""));
922 ignore_unused_variable_warning(diff);
924 #ifndef BOOST_NO_STD_LOCALE
926 m_stream << m_cresults;
929 // Extended formatting with a functor:
931 regex_constants::match_flag_type f = regex_constants::match_default;
932 OutputIterator out = static_object<OutputIterator>::get();
933 functor3<match_results_type> func3;
934 out = regex_format(out, m_cresults, func3, f);
935 out = regex_format(out, m_cresults, func3);
936 functor2<match_results_type> func2;
937 out = regex_format(out, m_cresults, func2, f);
938 out = regex_format(out, m_cresults, func2);
939 functor1<match_results_type> func1;
940 out = regex_format(out, m_cresults, func1, f);
941 out = regex_format(out, m_cresults, func1);
943 m_string += regex_format(m_cresults, func3, f);
944 m_string += regex_format(m_cresults, func3);
945 m_string += regex_format(m_cresults, func2, f);
946 m_string += regex_format(m_cresults, func2);
947 m_string += regex_format(m_cresults, func1, f);
948 m_string += regex_format(m_cresults, func1);
950 out = m_cresults.format(out, func3, f);
951 out = m_cresults.format(out, func3);
952 out = m_cresults.format(out, func2, f);
953 out = m_cresults.format(out, func2);
954 out = m_cresults.format(out, func1, f);
955 out = m_cresults.format(out, func1);
957 m_string += m_cresults.format(func3, f);
958 m_string += m_cresults.format(func3);
959 m_string += m_cresults.format(func2, f);
960 m_string += m_cresults.format(func2);
961 m_string += m_cresults.format(func1, f);
962 m_string += m_cresults.format(func1);
964 out = regex_replace(out, m_in, m_in, ce, func3, f);
965 out = regex_replace(out, m_in, m_in, ce, func3);
966 out = regex_replace(out, m_in, m_in, ce, func2, f);
967 out = regex_replace(out, m_in, m_in, ce, func2);
968 out = regex_replace(out, m_in, m_in, ce, func1, f);
969 out = regex_replace(out, m_in, m_in, ce, func1);
971 functor3<match_results<typename string_type::const_iterator> > func3s;
972 functor2<match_results<typename string_type::const_iterator> > func2s;
973 functor1<match_results<typename string_type::const_iterator> > func1s;
974 m_string += regex_replace(m_string, ce, func3s, f);
975 m_string += regex_replace(m_string, ce, func3s);
976 m_string += regex_replace(m_string, ce, func2s, f);
977 m_string += regex_replace(m_string, ce, func2s);
978 m_string += regex_replace(m_string, ce, func1s, f);
979 m_string += regex_replace(m_string, ce, func1s);
982 std::basic_ostream<value_type> m_stream;
983 sub_match_type m_sub;
984 pointer_type m_pointer;
985 string_type m_string;
986 const value_type m_char;
987 match_results_type m_results;
988 const match_results_type m_cresults;
992 BoostRegexConcept(const BoostRegexConcept&);
993 BoostRegexConcept& operator=(const BoostRegexConcept&);
996 #endif // BOOST_REGEX_TEST_STD