]> git.lyx.org Git - lyx.git/blob - boost/boost/regex/concepts.hpp
boost: update to 1.42.0
[lyx.git] / boost / boost / regex / concepts.hpp
1 /*
2  *
3  * Copyright (c) 2004
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         concepts.hpp
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: Declares regular expression concepts.
17   */
18
19 #ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED
20 #define BOOST_REGEX_CONCEPTS_HPP_INCLUDED
21
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>
29 #endif
30 #include <bitset>
31 #include <vector>
32 #include <iostream>
33
34 namespace boost{
35
36 //
37 // bitmask_archetype:
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:
41 //
42 typedef std::bitset<512> bitmask_archetype;
43 //
44 // char_architype:
45 // A strict model for the character type interface.
46 //
47 struct char_architype
48 {
49    // default constructable:
50    char_architype();
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);
56    // comparable:
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:
64    operator long()const;
65 };
66 //
67 // char_architype can not be used with basic_string:
68 //
69 } // namespace boost
70 namespace std{
71    template<> struct char_traits<boost::char_architype>
72    {
73       // The intent is that this template is not instantiated,
74       // but this typedef gives us a chance of compilation in
75       // case it is:
76       typedef boost::char_architype char_type;
77    };
78 }
79 namespace boost{
80 //
81 // regex_traits_architype:
82 // A strict interpretation of the regular expression traits class requirements.
83 //
84 template <class charT>
85 struct regex_traits_architype
86 {
87 public:
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;
94
95    static std::size_t length(const char_type* ) { return 0; }
96
97    charT translate(charT ) const { return charT(); }
98    charT translate_nocase(charT ) const { return static_object<charT>::get(); }
99
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(); }
106
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(); }
113
114    bool isctype(charT, char_class_type) const
115    { return false; }
116    int value(charT, int) const
117    { return 0; }
118
119    locale_type imbue(locale_type l)
120    { return l; }
121    locale_type getloc()const
122    { return static_object<locale_type>::get(); }
123
124 private:
125    // this type is not copyable:
126    regex_traits_architype(const regex_traits_architype&);
127    regex_traits_architype& operator=(const regex_traits_architype&);
128 };
129
130 //
131 // alter this to std::tr1, to test a std implementation:
132 //
133 #ifndef BOOST_TEST_TR1_REGEX
134 namespace global_regex_namespace = ::boost;
135 #else
136 namespace global_regex_namespace = ::std::tr1;
137 #endif
138
139 template <class Bitmask>
140 struct BitmaskConcept
141 {
142    void constraints() 
143    {
144       function_requires<CopyConstructibleConcept<Bitmask> >();
145       function_requires<AssignableConcept<Bitmask> >();
146
147       m_mask1 = m_mask2 | m_mask3;
148       m_mask1 = m_mask2 & m_mask3;
149       m_mask1 = m_mask2 ^ m_mask3;
150
151       m_mask1 = ~m_mask2;
152
153       m_mask1 |= m_mask2;
154       m_mask1 &= m_mask2;
155       m_mask1 ^= m_mask2;
156    }
157    Bitmask m_mask1, m_mask2, m_mask3;
158 };
159
160 template <class traits>
161 struct RegexTraitsConcept
162 {
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;
170
171    void constraints() 
172    {
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> >();
179
180       std::size_t n = traits::length(m_pointer);
181       ignore_unused_variable_warning(n);
182
183       char_type c = m_ctraits.translate(m_char);
184       ignore_unused_variable_warning(c);
185       c = m_ctraits.translate_nocase(m_char);
186       
187       //string_type::foobar bar;
188       string_type s1 = m_ctraits.transform(m_pointer, m_pointer);
189       ignore_unused_variable_warning(s1);
190
191       string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer);
192       ignore_unused_variable_warning(s2);
193
194       char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer);
195       ignore_unused_variable_warning(cc);
196
197       string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer);
198       ignore_unused_variable_warning(s3);
199
200       bool b = m_ctraits.isctype(m_char, cc);
201       ignore_unused_variable_warning(b);
202
203       int v = m_ctraits.value(m_char, 16);
204       ignore_unused_variable_warning(v);
205
206       locale_type l(m_ctraits.getloc());
207       m_traits.imbue(l);
208       ignore_unused_variable_warning(l);
209    }
210    traits m_traits;
211    const traits m_ctraits;
212    const char_type* m_pointer;
213    char_type m_char;
214 private:
215    RegexTraitsConcept& operator=(RegexTraitsConcept&);
216 };
217
218 //
219 // helper class to compute what traits class a regular expression type is using:
220 //
221 template <class Regex>
222 struct regex_traits_computer;
223
224 template <class charT, class traits>
225 struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> >
226 {
227    typedef traits type;
228 };
229
230 //
231 // BaseRegexConcept does not test anything dependent on basic_string,
232 // in case our charT does not have an associated char_traits:
233 //
234 template <class Regex>
235 struct BaseRegexConcept
236 {
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;
242
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;
252
253    void global_constraints()
254    {
255       //
256       // test non-template components:
257       //
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);
271
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);
288
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);
316
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);
319       e1 = except.code();
320
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> > >();
324    }
325    void constraints() 
326    {
327       global_constraints();
328
329       BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value));
330       flag_type opts
331          = Regex::icase
332          | Regex::nosubs
333          | Regex::optimize
334          | Regex::collate
335          | Regex::ECMAScript
336          | Regex::basic
337          | Regex::extended
338          | Regex::awk
339          | Regex::grep
340          | Regex::egrep;
341       ignore_unused_variable_warning(opts);
342
343       function_requires<DefaultConstructibleConcept<Regex> >();
344       function_requires<CopyConstructibleConcept<Regex> >();
345
346       // Regex constructors:
347       Regex e1(m_pointer);
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);
353       Regex e4(in1, in2);
354       ignore_unused_variable_warning(e4);
355       Regex e5(in1, in2, m_flags);
356       ignore_unused_variable_warning(e5);
357
358       // assign etc:
359       Regex e;
360       e = m_pointer;
361       e = e1;
362       e.assign(e1);
363       e.assign(m_pointer);
364       e.assign(m_pointer, m_flags);
365       e.assign(m_pointer, m_size, m_flags);
366       e.assign(in1, in2);
367       e.assign(in1, in2, m_flags);
368
369       // access:
370       const Regex ce;
371       unsigned i = ce.mark_count();
372       ignore_unused_variable_warning(i);
373       m_flags = ce.flags();
374       e.imbue(ce.getloc());
375       e.swap(e1);
376       
377       global_regex_namespace::swap(e, e1);
378
379       // sub_match:
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);
390       bi = m_sub.second;
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;
405
406       match_results_type m1;
407       mr_allocator_type at;
408       match_results_type m2(at);
409       match_results_type m3(m1);
410       m1 = m2;
411
412       int ival = 0;
413
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);
428
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);
439
440       mr_allocator_type at2 = m_cresults.get_allocator();
441       m_results.swap(m_results);
442       global_regex_namespace::swap(m_results, m_results);
443
444       // regex_match:
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);
461       // regex_search:
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);
478
479       // regex_iterator:
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);
498
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);
530    }
531
532    pointer_type m_pointer;
533    flag_type m_flags;
534    std::size_t m_size;
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;
540    OutIterator m_out;
541    BidiIterator m_in;
542    global_regex_namespace::regex_constants::match_flag_type m_mft;
543    global_regex_namespace::match_results<pointer_type> m_pmatch;
544
545    BaseRegexConcept();
546    BaseRegexConcept(const BaseRegexConcept&);
547    BaseRegexConcept& operator=(const BaseRegexConcept&);
548 };
549
550 //
551 // RegexConcept:
552 // Test every interface in the std:
553 //
554 template <class Regex>
555 struct RegexConcept
556 {
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;
561
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;
569
570
571    void constraints() 
572    {
573       function_requires<BaseRegexConcept<Regex> >();
574       // string based construct:
575       Regex e1(m_string);
576       ignore_unused_variable_warning(e1);
577       Regex e2(m_string, m_flags);
578       ignore_unused_variable_warning(e2);
579
580       // assign etc:
581       Regex e;
582       e = m_string;
583       e.assign(m_string);
584       e.assign(m_string, m_flags);
585
586       // sub_match:
587       string_type s(m_sub);
588       ignore_unused_variable_warning(s);
589       s = m_sub.str();
590       ignore_unused_variable_warning(s);
591       int i = m_sub.compare(m_string);
592       ignore_unused_variable_warning(i);
593
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);
598
599       bool b = m_sub == m_sub;
600       ignore_unused_variable_warning(b);
601       b = m_sub != m_sub;
602       ignore_unused_variable_warning(b);
603       b = m_sub <= m_sub;
604       ignore_unused_variable_warning(b);
605       b = m_sub <= m_sub;
606       ignore_unused_variable_warning(b);
607       b = m_sub > m_sub;
608       ignore_unused_variable_warning(b);
609       b = m_sub >= m_sub;
610       ignore_unused_variable_warning(b);
611
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);
624
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);
637
638       b = m_sub == m_char;
639       ignore_unused_variable_warning(b);
640       b = m_sub != m_char;
641       ignore_unused_variable_warning(b);
642       b = m_sub <= m_char;
643       ignore_unused_variable_warning(b);
644       b = m_sub <= m_char;
645       ignore_unused_variable_warning(b);
646       b = m_sub > m_char;
647       ignore_unused_variable_warning(b);
648       b = m_sub >= m_char;
649       ignore_unused_variable_warning(b);
650
651       b = m_char == m_sub;
652       ignore_unused_variable_warning(b);
653       b = m_char != m_sub;
654       ignore_unused_variable_warning(b);
655       b = m_char <= m_sub;
656       ignore_unused_variable_warning(b);
657       b = m_char <= m_sub;
658       ignore_unused_variable_warning(b);
659       b = m_char > m_sub;
660       ignore_unused_variable_warning(b);
661       b = m_char >= m_sub;
662       ignore_unused_variable_warning(b);
663
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);
676
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);
689
690       // match results:
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);
701
702       // regex_match:
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);
711
712       // regex_search:
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);
721
722       // regex_replace:
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);
729
730    }
731
732    flag_type m_flags;
733    string_type m_string;
734    const sub_match_type m_sub;
735    match_results_type m_results;
736    pointer_type m_pointer;
737    value_type m_char;
738    const match_results_type m_cresults;
739    OutIterator m_out;
740    BidiIterator m_in;
741    global_regex_namespace::regex_constants::match_flag_type m_mft;
742    global_regex_namespace::match_results<typename string_type::const_iterator> m_smatch;
743
744    RegexConcept();
745    RegexConcept(const RegexConcept&);
746    RegexConcept& operator=(const RegexConcept&);
747 };
748
749 #ifndef BOOST_REGEX_TEST_STD
750
751 template <class M>
752 struct functor1
753 {
754    typedef typename M::char_type char_type;
755    const char_type* operator()(const M&)
756    {
757       static const char_type c = static_cast<char_type>(0);
758       return &c;
759    }
760 };
761 template <class M>
762 struct functor1b
763 {
764    typedef typename M::char_type char_type;
765    std::vector<char_type> operator()(const M&)
766    {
767       static const std::vector<char_type> c;
768       return c;
769    }
770 };
771 template <class M>
772 struct functor2
773 {
774    template <class O>
775    O operator()(const M& /*m*/, O i)
776    {
777       return i;
778    }
779 };
780 template <class M>
781 struct functor3
782 {
783    template <class O>
784    O operator()(const M& /*m*/, O i, regex_constants::match_flag_type)
785    {
786       return i;
787    }
788 };
789
790 //
791 // BoostRegexConcept:
792 // Test every interface in the Boost implementation:
793 //
794 template <class Regex>
795 struct BoostRegexConcept
796 {
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;
801
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;
810
811    void constraints() 
812    {
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;
829
830       (void)mopts;
831
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);
836       const Regex ce, ce2;
837 #ifndef BOOST_NO_STD_LOCALE
838       m_stream << ce;
839 #endif
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);
846       bool b = ce == ce2;
847       ignore_unused_variable_warning(b);
848       b = ce.empty();
849       ignore_unused_variable_warning(b);
850       b = ce != ce2;
851       ignore_unused_variable_warning(b);
852       b = ce < ce2;
853       ignore_unused_variable_warning(b);
854       b = ce > ce2;
855       ignore_unused_variable_warning(b);
856       b = ce <= ce2;
857       ignore_unused_variable_warning(b);
858       b = ce >= ce2;
859       ignore_unused_variable_warning(b);
860       i = ce.status();
861       ignore_unused_variable_warning(i);
862       size_type s = ce.max_size();
863       ignore_unused_variable_warning(s);
864       s = ce.size();
865       ignore_unused_variable_warning(s);
866       const_iterator pi = ce.begin();
867       ignore_unused_variable_warning(pi);
868       pi = ce.end();
869       ignore_unused_variable_warning(pi);
870       string_type s2 = ce.str();
871       ignore_unused_variable_warning(s2);
872
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);
887
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);
905
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);
923
924 #ifndef BOOST_NO_STD_LOCALE
925       m_stream << m_sub;
926       m_stream << m_cresults;
927 #endif
928       //
929       // Extended formatting with a functor:
930       //
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);
942
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);
949
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);
956
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);
963
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);
970
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);
980    }
981
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;
989    BidiIterator m_in;
990
991    BoostRegexConcept();
992    BoostRegexConcept(const BoostRegexConcept&);
993    BoostRegexConcept& operator=(const BoostRegexConcept&);
994 };
995
996 #endif // BOOST_REGEX_TEST_STD
997
998 }
999
1000 #endif