]> git.lyx.org Git - lyx.git/blob - boost/boost/regex/concepts.hpp
boost: update to version 1.40
[lyx.git] / boost / boost / regex / concepts.hpp
1 /*\r
2  *\r
3  * Copyright (c) 2004\r
4  * John Maddock\r
5  *\r
6  * Use, modification and distribution are subject to the \r
7  * Boost Software License, Version 1.0. (See accompanying file \r
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\r
9  *\r
10  */\r
11  \r
12  /*\r
13   *   LOCATION:    see http://www.boost.org for most recent version.\r
14   *   FILE         concepts.hpp\r
15   *   VERSION      see <boost/version.hpp>\r
16   *   DESCRIPTION: Declares regular expression concepts.\r
17   */\r
18 \r
19 #ifndef BOOST_REGEX_CONCEPTS_HPP_INCLUDED\r
20 #define BOOST_REGEX_CONCEPTS_HPP_INCLUDED\r
21 \r
22 #include <boost/concept_archetype.hpp>\r
23 #include <boost/concept_check.hpp>\r
24 #include <boost/type_traits/is_enum.hpp>\r
25 #include <boost/type_traits/is_base_and_derived.hpp>\r
26 #include <boost/static_assert.hpp>\r
27 #ifndef BOOST_TEST_TR1_REGEX\r
28 #include <boost/regex.hpp>\r
29 #endif\r
30 #include <bitset>\r
31 #include <vector>\r
32 #include <iostream>\r
33 \r
34 namespace boost{\r
35 \r
36 //\r
37 // bitmask_archetype:\r
38 // this can be either an integer type, an enum, or a std::bitset,\r
39 // we use the latter as the architype as it offers the "strictest"\r
40 // of the possible interfaces:\r
41 //\r
42 typedef std::bitset<512> bitmask_archetype;\r
43 //\r
44 // char_architype:\r
45 // A strict model for the character type interface.\r
46 //\r
47 struct char_architype\r
48 {\r
49    // default constructable:\r
50    char_architype();\r
51    // copy constructable / assignable:\r
52    char_architype(const char_architype&);\r
53    char_architype& operator=(const char_architype&);\r
54    // constructable from an integral value:\r
55    char_architype(unsigned long val);\r
56    // comparable:\r
57    bool operator==(const char_architype&)const;\r
58    bool operator!=(const char_architype&)const;\r
59    bool operator<(const char_architype&)const;\r
60    bool operator<=(const char_architype&)const;\r
61    bool operator>=(const char_architype&)const;\r
62    bool operator>(const char_architype&)const;\r
63    // conversion to integral type:\r
64    operator long()const;\r
65 };\r
66 //\r
67 // char_architype can not be used with basic_string:\r
68 //\r
69 } // namespace boost\r
70 namespace std{\r
71    template<> struct char_traits<boost::char_architype>\r
72    {\r
73       // The intent is that this template is not instantiated,\r
74       // but this typedef gives us a chance of compilation in\r
75       // case it is:\r
76       typedef boost::char_architype char_type;\r
77    };\r
78 }\r
79 namespace boost{\r
80 //\r
81 // regex_traits_architype:\r
82 // A strict interpretation of the regular expression traits class requirements.\r
83 //\r
84 template <class charT>\r
85 struct regex_traits_architype\r
86 {\r
87 public:\r
88    regex_traits_architype();\r
89    typedef charT char_type;\r
90    // typedef std::size_t size_type;\r
91    typedef std::vector<char_type> string_type;\r
92    typedef copy_constructible_archetype<assignable_archetype<> > locale_type;\r
93    typedef bitmask_archetype char_class_type;\r
94 \r
95    static std::size_t length(const char_type* ) { return 0; }\r
96 \r
97    charT translate(charT ) const { return charT(); }\r
98    charT translate_nocase(charT ) const { return static_object<charT>::get(); }\r
99 \r
100    template <class ForwardIterator>\r
101    string_type transform(ForwardIterator , ForwardIterator ) const\r
102    { return static_object<string_type>::get(); }\r
103    template <class ForwardIterator>\r
104    string_type transform_primary(ForwardIterator , ForwardIterator ) const\r
105    { return static_object<string_type>::get(); }\r
106 \r
107    template <class ForwardIterator>\r
108    char_class_type lookup_classname(ForwardIterator , ForwardIterator ) const\r
109    { return static_object<char_class_type>::get(); }\r
110    template <class ForwardIterator>\r
111    string_type lookup_collatename(ForwardIterator , ForwardIterator ) const\r
112    { return static_object<string_type>::get(); }\r
113 \r
114    bool isctype(charT, char_class_type) const\r
115    { return false; }\r
116    int value(charT, int) const\r
117    { return 0; }\r
118 \r
119    locale_type imbue(locale_type l)\r
120    { return l; }\r
121    locale_type getloc()const\r
122    { return static_object<locale_type>::get(); }\r
123 \r
124 private:\r
125    // this type is not copyable:\r
126    regex_traits_architype(const regex_traits_architype&);\r
127    regex_traits_architype& operator=(const regex_traits_architype&);\r
128 };\r
129 \r
130 //\r
131 // alter this to std::tr1, to test a std implementation:\r
132 //\r
133 #ifndef BOOST_TEST_TR1_REGEX\r
134 namespace global_regex_namespace = ::boost;\r
135 #else\r
136 namespace global_regex_namespace = ::std::tr1;\r
137 #endif\r
138 \r
139 template <class Bitmask>\r
140 struct BitmaskConcept\r
141 {\r
142    void constraints() \r
143    {\r
144       function_requires<CopyConstructibleConcept<Bitmask> >();\r
145       function_requires<AssignableConcept<Bitmask> >();\r
146 \r
147       m_mask1 = m_mask2 | m_mask3;\r
148       m_mask1 = m_mask2 & m_mask3;\r
149       m_mask1 = m_mask2 ^ m_mask3;\r
150 \r
151       m_mask1 = ~m_mask2;\r
152 \r
153       m_mask1 |= m_mask2;\r
154       m_mask1 &= m_mask2;\r
155       m_mask1 ^= m_mask2;\r
156    }\r
157    Bitmask m_mask1, m_mask2, m_mask3;\r
158 };\r
159 \r
160 template <class traits>\r
161 struct RegexTraitsConcept\r
162 {\r
163    RegexTraitsConcept();\r
164    // required typedefs:\r
165    typedef typename traits::char_type char_type;\r
166    // typedef typename traits::size_type size_type;\r
167    typedef typename traits::string_type string_type;\r
168    typedef typename traits::locale_type locale_type;\r
169    typedef typename traits::char_class_type char_class_type;\r
170 \r
171    void constraints() \r
172    {\r
173       //function_requires<UnsignedIntegerConcept<size_type> >();\r
174       function_requires<RandomAccessContainerConcept<string_type> >();\r
175       function_requires<DefaultConstructibleConcept<locale_type> >();\r
176       function_requires<CopyConstructibleConcept<locale_type> >();\r
177       function_requires<AssignableConcept<locale_type> >();\r
178       function_requires<BitmaskConcept<char_class_type> >();\r
179 \r
180       std::size_t n = traits::length(m_pointer);\r
181       ignore_unused_variable_warning(n);\r
182 \r
183       char_type c = m_ctraits.translate(m_char);\r
184       ignore_unused_variable_warning(c);\r
185       c = m_ctraits.translate_nocase(m_char);\r
186       \r
187       //string_type::foobar bar;\r
188       string_type s1 = m_ctraits.transform(m_pointer, m_pointer);\r
189       ignore_unused_variable_warning(s1);\r
190 \r
191       string_type s2 = m_ctraits.transform_primary(m_pointer, m_pointer);\r
192       ignore_unused_variable_warning(s2);\r
193 \r
194       char_class_type cc = m_ctraits.lookup_classname(m_pointer, m_pointer);\r
195       ignore_unused_variable_warning(cc);\r
196 \r
197       string_type s3 = m_ctraits.lookup_collatename(m_pointer, m_pointer);\r
198       ignore_unused_variable_warning(s3);\r
199 \r
200       bool b = m_ctraits.isctype(m_char, cc);\r
201       ignore_unused_variable_warning(b);\r
202 \r
203       int v = m_ctraits.value(m_char, 16);\r
204       ignore_unused_variable_warning(v);\r
205 \r
206       locale_type l(m_ctraits.getloc());\r
207       m_traits.imbue(l);\r
208       ignore_unused_variable_warning(l);\r
209    }\r
210    traits m_traits;\r
211    const traits m_ctraits;\r
212    const char_type* m_pointer;\r
213    char_type m_char;\r
214 private:\r
215    RegexTraitsConcept& operator=(RegexTraitsConcept&);\r
216 };\r
217 \r
218 //\r
219 // helper class to compute what traits class a regular expression type is using:\r
220 //\r
221 template <class Regex>\r
222 struct regex_traits_computer;\r
223 \r
224 template <class charT, class traits>\r
225 struct regex_traits_computer< global_regex_namespace::basic_regex<charT, traits> >\r
226 {\r
227    typedef traits type;\r
228 };\r
229 \r
230 //\r
231 // BaseRegexConcept does not test anything dependent on basic_string,\r
232 // in case our charT does not have an associated char_traits:\r
233 //\r
234 template <class Regex>\r
235 struct BaseRegexConcept\r
236 {\r
237    typedef typename Regex::value_type value_type;\r
238    //typedef typename Regex::size_type size_type;\r
239    typedef typename Regex::flag_type flag_type;\r
240    typedef typename Regex::locale_type locale_type;\r
241    typedef input_iterator_archetype<value_type> input_iterator_type;\r
242 \r
243    // derived test types:\r
244    typedef const value_type* pointer_type;\r
245    typedef bidirectional_iterator_archetype<value_type> BidiIterator;\r
246    typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;\r
247    typedef global_regex_namespace::match_results<BidiIterator> match_results_type;\r
248    typedef output_iterator_archetype<value_type> OutIterator;\r
249    typedef typename regex_traits_computer<Regex>::type traits_type;\r
250    typedef global_regex_namespace::regex_iterator<BidiIterator, value_type, traits_type> regex_iterator_type;\r
251    typedef global_regex_namespace::regex_token_iterator<BidiIterator, value_type, traits_type> regex_token_iterator_type;\r
252 \r
253    void global_constraints()\r
254    {\r
255       //\r
256       // test non-template components:\r
257       //\r
258       function_requires<BitmaskConcept<global_regex_namespace::regex_constants::syntax_option_type> >();\r
259       global_regex_namespace::regex_constants::syntax_option_type opts\r
260          = global_regex_namespace::regex_constants::icase\r
261          | global_regex_namespace::regex_constants::nosubs\r
262          | global_regex_namespace::regex_constants::optimize\r
263          | global_regex_namespace::regex_constants::collate\r
264          | global_regex_namespace::regex_constants::ECMAScript\r
265          | global_regex_namespace::regex_constants::basic\r
266          | global_regex_namespace::regex_constants::extended\r
267          | global_regex_namespace::regex_constants::awk\r
268          | global_regex_namespace::regex_constants::grep\r
269          | global_regex_namespace::regex_constants::egrep;\r
270       ignore_unused_variable_warning(opts);\r
271 \r
272       function_requires<BitmaskConcept<global_regex_namespace::regex_constants::match_flag_type> >();\r
273       global_regex_namespace::regex_constants::match_flag_type mopts\r
274          = global_regex_namespace::regex_constants::match_default\r
275          | global_regex_namespace::regex_constants::match_not_bol\r
276          | global_regex_namespace::regex_constants::match_not_eol\r
277          | global_regex_namespace::regex_constants::match_not_bow\r
278          | global_regex_namespace::regex_constants::match_not_eow\r
279          | global_regex_namespace::regex_constants::match_any\r
280          | global_regex_namespace::regex_constants::match_not_null\r
281          | global_regex_namespace::regex_constants::match_continuous\r
282          | global_regex_namespace::regex_constants::match_prev_avail\r
283          | global_regex_namespace::regex_constants::format_default\r
284          | global_regex_namespace::regex_constants::format_sed\r
285          | global_regex_namespace::regex_constants::format_no_copy\r
286          | global_regex_namespace::regex_constants::format_first_only;\r
287       ignore_unused_variable_warning(mopts);\r
288 \r
289       BOOST_STATIC_ASSERT((::boost::is_enum<global_regex_namespace::regex_constants::error_type>::value));\r
290       global_regex_namespace::regex_constants::error_type e1 = global_regex_namespace::regex_constants::error_collate;\r
291       ignore_unused_variable_warning(e1);\r
292       e1 = global_regex_namespace::regex_constants::error_ctype;\r
293       ignore_unused_variable_warning(e1);\r
294       e1 = global_regex_namespace::regex_constants::error_escape;\r
295       ignore_unused_variable_warning(e1);\r
296       e1 = global_regex_namespace::regex_constants::error_backref;\r
297       ignore_unused_variable_warning(e1);\r
298       e1 = global_regex_namespace::regex_constants::error_brack;\r
299       ignore_unused_variable_warning(e1);\r
300       e1 = global_regex_namespace::regex_constants::error_paren;\r
301       ignore_unused_variable_warning(e1);\r
302       e1 = global_regex_namespace::regex_constants::error_brace;\r
303       ignore_unused_variable_warning(e1);\r
304       e1 = global_regex_namespace::regex_constants::error_badbrace;\r
305       ignore_unused_variable_warning(e1);\r
306       e1 = global_regex_namespace::regex_constants::error_range;\r
307       ignore_unused_variable_warning(e1);\r
308       e1 = global_regex_namespace::regex_constants::error_space;\r
309       ignore_unused_variable_warning(e1);\r
310       e1 = global_regex_namespace::regex_constants::error_badrepeat;\r
311       ignore_unused_variable_warning(e1);\r
312       e1 = global_regex_namespace::regex_constants::error_complexity;\r
313       ignore_unused_variable_warning(e1);\r
314       e1 = global_regex_namespace::regex_constants::error_stack;\r
315       ignore_unused_variable_warning(e1);\r
316 \r
317       BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::runtime_error, global_regex_namespace::regex_error>::value  ));\r
318       const global_regex_namespace::regex_error except(e1);\r
319       e1 = except.code();\r
320 \r
321       typedef typename Regex::value_type value_type;\r
322       function_requires< RegexTraitsConcept<global_regex_namespace::regex_traits<char> > >();\r
323       function_requires< BaseRegexConcept<global_regex_namespace::basic_regex<char> > >();\r
324    }\r
325    void constraints() \r
326    {\r
327       global_constraints();\r
328 \r
329       BOOST_STATIC_ASSERT((::boost::is_same< flag_type, global_regex_namespace::regex_constants::syntax_option_type>::value));\r
330       flag_type opts\r
331          = Regex::icase\r
332          | Regex::nosubs\r
333          | Regex::optimize\r
334          | Regex::collate\r
335          | Regex::ECMAScript\r
336          | Regex::basic\r
337          | Regex::extended\r
338          | Regex::awk\r
339          | Regex::grep\r
340          | Regex::egrep;\r
341       ignore_unused_variable_warning(opts);\r
342 \r
343       function_requires<DefaultConstructibleConcept<Regex> >();\r
344       function_requires<CopyConstructibleConcept<Regex> >();\r
345 \r
346       // Regex constructors:\r
347       Regex e1(m_pointer);\r
348       ignore_unused_variable_warning(e1);\r
349       Regex e2(m_pointer, m_flags);\r
350       ignore_unused_variable_warning(e2);\r
351       Regex e3(m_pointer, m_size, m_flags);\r
352       ignore_unused_variable_warning(e3);\r
353       Regex e4(in1, in2);\r
354       ignore_unused_variable_warning(e4);\r
355       Regex e5(in1, in2, m_flags);\r
356       ignore_unused_variable_warning(e5);\r
357 \r
358       // assign etc:\r
359       Regex e;\r
360       e = m_pointer;\r
361       e = e1;\r
362       e.assign(e1);\r
363       e.assign(m_pointer);\r
364       e.assign(m_pointer, m_flags);\r
365       e.assign(m_pointer, m_size, m_flags);\r
366       e.assign(in1, in2);\r
367       e.assign(in1, in2, m_flags);\r
368 \r
369       // access:\r
370       const Regex ce;\r
371       unsigned i = ce.mark_count();\r
372       ignore_unused_variable_warning(i);\r
373       m_flags = ce.flags();\r
374       e.imbue(ce.getloc());\r
375       e.swap(e1);\r
376       \r
377       global_regex_namespace::swap(e, e1);\r
378 \r
379       // sub_match:\r
380       BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::pair<BidiIterator, BidiIterator>, sub_match_type>::value));\r
381       typedef typename sub_match_type::value_type sub_value_type;\r
382       typedef typename sub_match_type::difference_type sub_diff_type;\r
383       typedef typename sub_match_type::iterator sub_iter_type;\r
384       BOOST_STATIC_ASSERT((::boost::is_same<sub_value_type, value_type>::value));\r
385       BOOST_STATIC_ASSERT((::boost::is_same<sub_iter_type, BidiIterator>::value));\r
386       bool b = m_sub.matched;\r
387       ignore_unused_variable_warning(b);\r
388       BidiIterator bi = m_sub.first;\r
389       ignore_unused_variable_warning(bi);\r
390       bi = m_sub.second;\r
391       ignore_unused_variable_warning(bi);\r
392       sub_diff_type diff = m_sub.length();\r
393       ignore_unused_variable_warning(diff);\r
394       // match_results tests:\r
395       typedef typename match_results_type::value_type mr_value_type;\r
396       typedef typename match_results_type::const_reference mr_const_reference;\r
397       typedef typename match_results_type::reference mr_reference;\r
398       typedef typename match_results_type::const_iterator mr_const_iterator;\r
399       typedef typename match_results_type::iterator mr_iterator;\r
400       typedef typename match_results_type::difference_type mr_difference_type;\r
401       typedef typename match_results_type::size_type mr_size_type;\r
402       typedef typename match_results_type::allocator_type mr_allocator_type;\r
403       typedef typename match_results_type::char_type mr_char_type;\r
404       typedef typename match_results_type::string_type mr_string_type;\r
405 \r
406       match_results_type m1;\r
407       mr_allocator_type at;\r
408       match_results_type m2(at);\r
409       match_results_type m3(m1);\r
410       m1 = m2;\r
411 \r
412       int ival = 0;\r
413 \r
414       mr_size_type mrs = m_cresults.size();\r
415       ignore_unused_variable_warning(mrs);\r
416       mrs = m_cresults.max_size();\r
417       ignore_unused_variable_warning(mrs);\r
418       b = m_cresults.empty();\r
419       ignore_unused_variable_warning(b);\r
420       mr_difference_type mrd = m_cresults.length();\r
421       ignore_unused_variable_warning(mrd);\r
422       mrd = m_cresults.length(ival);\r
423       ignore_unused_variable_warning(mrd);\r
424       mrd = m_cresults.position();\r
425       ignore_unused_variable_warning(mrd);\r
426       mrd = m_cresults.position(mrs);\r
427       ignore_unused_variable_warning(mrd);\r
428 \r
429       mr_const_reference mrcr = m_cresults[ival];\r
430       ignore_unused_variable_warning(mrcr);\r
431       mr_const_reference mrcr2 = m_cresults.prefix();\r
432       ignore_unused_variable_warning(mrcr2);\r
433       mr_const_reference mrcr3 = m_cresults.suffix();\r
434       ignore_unused_variable_warning(mrcr3);\r
435       mr_const_iterator mrci = m_cresults.begin();\r
436       ignore_unused_variable_warning(mrci);\r
437       mrci = m_cresults.end();\r
438       ignore_unused_variable_warning(mrci);\r
439 \r
440       mr_allocator_type at2 = m_cresults.get_allocator();\r
441       m_results.swap(m_results);\r
442       global_regex_namespace::swap(m_results, m_results);\r
443 \r
444       // regex_match:\r
445       b = global_regex_namespace::regex_match(m_in, m_in, m_results, e);\r
446       ignore_unused_variable_warning(b);\r
447       b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft);\r
448       ignore_unused_variable_warning(b);\r
449       b = global_regex_namespace::regex_match(m_in, m_in, e);\r
450       ignore_unused_variable_warning(b);\r
451       b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft);\r
452       ignore_unused_variable_warning(b);\r
453       b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e);\r
454       ignore_unused_variable_warning(b);\r
455       b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft);\r
456       ignore_unused_variable_warning(b);\r
457       b = global_regex_namespace::regex_match(m_pointer, e);\r
458       ignore_unused_variable_warning(b);\r
459       b = global_regex_namespace::regex_match(m_pointer, e, m_mft);\r
460       ignore_unused_variable_warning(b);\r
461       // regex_search:\r
462       b = global_regex_namespace::regex_search(m_in, m_in, m_results, e);\r
463       ignore_unused_variable_warning(b);\r
464       b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft);\r
465       ignore_unused_variable_warning(b);\r
466       b = global_regex_namespace::regex_search(m_in, m_in, e);\r
467       ignore_unused_variable_warning(b);\r
468       b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft);\r
469       ignore_unused_variable_warning(b);\r
470       b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e);\r
471       ignore_unused_variable_warning(b);\r
472       b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft);\r
473       ignore_unused_variable_warning(b);\r
474       b = global_regex_namespace::regex_search(m_pointer, e);\r
475       ignore_unused_variable_warning(b);\r
476       b = global_regex_namespace::regex_search(m_pointer, e, m_mft);\r
477       ignore_unused_variable_warning(b);\r
478 \r
479       // regex_iterator:\r
480       typedef typename regex_iterator_type::regex_type rit_regex_type;\r
481       typedef typename regex_iterator_type::value_type rit_value_type;\r
482       typedef typename regex_iterator_type::difference_type rit_difference_type;\r
483       typedef typename regex_iterator_type::pointer rit_pointer;\r
484       typedef typename regex_iterator_type::reference rit_reference;\r
485       typedef typename regex_iterator_type::iterator_category rit_iterator_category;\r
486       BOOST_STATIC_ASSERT((::boost::is_same<rit_regex_type, Regex>::value));\r
487       BOOST_STATIC_ASSERT((::boost::is_same<rit_value_type, match_results_type>::value));\r
488       BOOST_STATIC_ASSERT((::boost::is_same<rit_difference_type, std::ptrdiff_t>::value));\r
489       BOOST_STATIC_ASSERT((::boost::is_same<rit_pointer, const match_results_type*>::value));\r
490       BOOST_STATIC_ASSERT((::boost::is_same<rit_reference, const match_results_type&>::value));\r
491       BOOST_STATIC_ASSERT((::boost::is_convertible<rit_iterator_category*, std::forward_iterator_tag*>::value));\r
492       // this takes care of most of the checks needed:\r
493       function_requires<ForwardIteratorConcept<regex_iterator_type> >();\r
494       regex_iterator_type iter1(m_in, m_in, e);\r
495       ignore_unused_variable_warning(iter1);\r
496       regex_iterator_type iter2(m_in, m_in, e, m_mft);\r
497       ignore_unused_variable_warning(iter2);\r
498 \r
499       // regex_token_iterator:\r
500       typedef typename regex_token_iterator_type::regex_type rtit_regex_type;\r
501       typedef typename regex_token_iterator_type::value_type rtit_value_type;\r
502       typedef typename regex_token_iterator_type::difference_type rtit_difference_type;\r
503       typedef typename regex_token_iterator_type::pointer rtit_pointer;\r
504       typedef typename regex_token_iterator_type::reference rtit_reference;\r
505       typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category;\r
506       BOOST_STATIC_ASSERT((::boost::is_same<rtit_regex_type, Regex>::value));\r
507       BOOST_STATIC_ASSERT((::boost::is_same<rtit_value_type, sub_match_type>::value));\r
508       BOOST_STATIC_ASSERT((::boost::is_same<rtit_difference_type, std::ptrdiff_t>::value));\r
509       BOOST_STATIC_ASSERT((::boost::is_same<rtit_pointer, const sub_match_type*>::value));\r
510       BOOST_STATIC_ASSERT((::boost::is_same<rtit_reference, const sub_match_type&>::value));\r
511       BOOST_STATIC_ASSERT((::boost::is_convertible<rtit_iterator_category*, std::forward_iterator_tag*>::value));\r
512       // this takes care of most of the checks needed:\r
513       function_requires<ForwardIteratorConcept<regex_token_iterator_type> >();\r
514       regex_token_iterator_type ti1(m_in, m_in, e);\r
515       ignore_unused_variable_warning(ti1);\r
516       regex_token_iterator_type ti2(m_in, m_in, e, 0);\r
517       ignore_unused_variable_warning(ti2);\r
518       regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft);\r
519       ignore_unused_variable_warning(ti3);\r
520       std::vector<int> subs;\r
521       regex_token_iterator_type ti4(m_in, m_in, e, subs);\r
522       ignore_unused_variable_warning(ti4);\r
523       regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft);\r
524       ignore_unused_variable_warning(ti5);\r
525       static const int i_array[3] = { 1, 2, 3, };\r
526       regex_token_iterator_type ti6(m_in, m_in, e, i_array);\r
527       ignore_unused_variable_warning(ti6);\r
528       regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft);\r
529       ignore_unused_variable_warning(ti7);\r
530    }\r
531 \r
532    pointer_type m_pointer;\r
533    flag_type m_flags;\r
534    std::size_t m_size;\r
535    input_iterator_type in1, in2;\r
536    const sub_match_type m_sub;\r
537    const value_type m_char;\r
538    match_results_type m_results;\r
539    const match_results_type m_cresults;\r
540    OutIterator m_out;\r
541    BidiIterator m_in;\r
542    global_regex_namespace::regex_constants::match_flag_type m_mft;\r
543    global_regex_namespace::match_results<pointer_type> m_pmatch;\r
544 \r
545    BaseRegexConcept();\r
546    BaseRegexConcept(const BaseRegexConcept&);\r
547    BaseRegexConcept& operator=(const BaseRegexConcept&);\r
548 };\r
549 \r
550 //\r
551 // RegexConcept:\r
552 // Test every interface in the std:\r
553 //\r
554 template <class Regex>\r
555 struct RegexConcept\r
556 {\r
557    typedef typename Regex::value_type value_type;\r
558    //typedef typename Regex::size_type size_type;\r
559    typedef typename Regex::flag_type flag_type;\r
560    typedef typename Regex::locale_type locale_type;\r
561 \r
562    // derived test types:\r
563    typedef const value_type* pointer_type;\r
564    typedef std::basic_string<value_type> string_type;\r
565    typedef boost::bidirectional_iterator_archetype<value_type> BidiIterator;\r
566    typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;\r
567    typedef global_regex_namespace::match_results<BidiIterator> match_results_type;\r
568    typedef output_iterator_archetype<value_type> OutIterator;\r
569 \r
570 \r
571    void constraints() \r
572    {\r
573       function_requires<BaseRegexConcept<Regex> >();\r
574       // string based construct:\r
575       Regex e1(m_string);\r
576       ignore_unused_variable_warning(e1);\r
577       Regex e2(m_string, m_flags);\r
578       ignore_unused_variable_warning(e2);\r
579 \r
580       // assign etc:\r
581       Regex e;\r
582       e = m_string;\r
583       e.assign(m_string);\r
584       e.assign(m_string, m_flags);\r
585 \r
586       // sub_match:\r
587       string_type s(m_sub);\r
588       ignore_unused_variable_warning(s);\r
589       s = m_sub.str();\r
590       ignore_unused_variable_warning(s);\r
591       int i = m_sub.compare(m_string);\r
592       ignore_unused_variable_warning(i);\r
593 \r
594       int i2 = m_sub.compare(m_sub);\r
595       ignore_unused_variable_warning(i2);\r
596       i2 = m_sub.compare(m_pointer);\r
597       ignore_unused_variable_warning(i2);\r
598 \r
599       bool b = m_sub == m_sub;\r
600       ignore_unused_variable_warning(b);\r
601       b = m_sub != m_sub;\r
602       ignore_unused_variable_warning(b);\r
603       b = m_sub <= m_sub;\r
604       ignore_unused_variable_warning(b);\r
605       b = m_sub <= m_sub;\r
606       ignore_unused_variable_warning(b);\r
607       b = m_sub > m_sub;\r
608       ignore_unused_variable_warning(b);\r
609       b = m_sub >= m_sub;\r
610       ignore_unused_variable_warning(b);\r
611 \r
612       b = m_sub == m_pointer;\r
613       ignore_unused_variable_warning(b);\r
614       b = m_sub != m_pointer;\r
615       ignore_unused_variable_warning(b);\r
616       b = m_sub <= m_pointer;\r
617       ignore_unused_variable_warning(b);\r
618       b = m_sub <= m_pointer;\r
619       ignore_unused_variable_warning(b);\r
620       b = m_sub > m_pointer;\r
621       ignore_unused_variable_warning(b);\r
622       b = m_sub >= m_pointer;\r
623       ignore_unused_variable_warning(b);\r
624 \r
625       b = m_pointer == m_sub;\r
626       ignore_unused_variable_warning(b);\r
627       b = m_pointer != m_sub;\r
628       ignore_unused_variable_warning(b);\r
629       b = m_pointer <= m_sub;\r
630       ignore_unused_variable_warning(b);\r
631       b = m_pointer <= m_sub;\r
632       ignore_unused_variable_warning(b);\r
633       b = m_pointer > m_sub;\r
634       ignore_unused_variable_warning(b);\r
635       b = m_pointer >= m_sub;\r
636       ignore_unused_variable_warning(b);\r
637 \r
638       b = m_sub == m_char;\r
639       ignore_unused_variable_warning(b);\r
640       b = m_sub != m_char;\r
641       ignore_unused_variable_warning(b);\r
642       b = m_sub <= m_char;\r
643       ignore_unused_variable_warning(b);\r
644       b = m_sub <= m_char;\r
645       ignore_unused_variable_warning(b);\r
646       b = m_sub > m_char;\r
647       ignore_unused_variable_warning(b);\r
648       b = m_sub >= m_char;\r
649       ignore_unused_variable_warning(b);\r
650 \r
651       b = m_char == m_sub;\r
652       ignore_unused_variable_warning(b);\r
653       b = m_char != m_sub;\r
654       ignore_unused_variable_warning(b);\r
655       b = m_char <= m_sub;\r
656       ignore_unused_variable_warning(b);\r
657       b = m_char <= m_sub;\r
658       ignore_unused_variable_warning(b);\r
659       b = m_char > m_sub;\r
660       ignore_unused_variable_warning(b);\r
661       b = m_char >= m_sub;\r
662       ignore_unused_variable_warning(b);\r
663 \r
664       b = m_sub == m_string;\r
665       ignore_unused_variable_warning(b);\r
666       b = m_sub != m_string;\r
667       ignore_unused_variable_warning(b);\r
668       b = m_sub <= m_string;\r
669       ignore_unused_variable_warning(b);\r
670       b = m_sub <= m_string;\r
671       ignore_unused_variable_warning(b);\r
672       b = m_sub > m_string;\r
673       ignore_unused_variable_warning(b);\r
674       b = m_sub >= m_string;\r
675       ignore_unused_variable_warning(b);\r
676 \r
677       b = m_string == m_sub;\r
678       ignore_unused_variable_warning(b);\r
679       b = m_string != m_sub;\r
680       ignore_unused_variable_warning(b);\r
681       b = m_string <= m_sub;\r
682       ignore_unused_variable_warning(b);\r
683       b = m_string <= m_sub;\r
684       ignore_unused_variable_warning(b);\r
685       b = m_string > m_sub;\r
686       ignore_unused_variable_warning(b);\r
687       b = m_string >= m_sub;\r
688       ignore_unused_variable_warning(b);\r
689 \r
690       // match results:\r
691       m_string = m_results.str();\r
692       ignore_unused_variable_warning(m_string);\r
693       m_string = m_results.str(0);\r
694       ignore_unused_variable_warning(m_string);\r
695       m_out = m_cresults.format(m_out, m_string);\r
696       m_out = m_cresults.format(m_out, m_string, m_mft);\r
697       m_string = m_cresults.format(m_string);\r
698       ignore_unused_variable_warning(m_string);\r
699       m_string = m_cresults.format(m_string, m_mft);\r
700       ignore_unused_variable_warning(m_string);\r
701 \r
702       // regex_match:\r
703       b = global_regex_namespace::regex_match(m_string, m_smatch, e);\r
704       ignore_unused_variable_warning(b);\r
705       b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft);\r
706       ignore_unused_variable_warning(b);\r
707       b = global_regex_namespace::regex_match(m_string, e);\r
708       ignore_unused_variable_warning(b);\r
709       b = global_regex_namespace::regex_match(m_string, e, m_mft);\r
710       ignore_unused_variable_warning(b);\r
711 \r
712       // regex_search:\r
713       b = global_regex_namespace::regex_search(m_string, m_smatch, e);\r
714       ignore_unused_variable_warning(b);\r
715       b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft);\r
716       ignore_unused_variable_warning(b);\r
717       b = global_regex_namespace::regex_search(m_string, e);\r
718       ignore_unused_variable_warning(b);\r
719       b = global_regex_namespace::regex_search(m_string, e, m_mft);\r
720       ignore_unused_variable_warning(b);\r
721 \r
722       // regex_replace:\r
723       m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft);\r
724       m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string);\r
725       m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft);\r
726       ignore_unused_variable_warning(m_string);\r
727       m_string = global_regex_namespace::regex_replace(m_string, e, m_string);\r
728       ignore_unused_variable_warning(m_string);\r
729 \r
730    }\r
731 \r
732    flag_type m_flags;\r
733    string_type m_string;\r
734    const sub_match_type m_sub;\r
735    match_results_type m_results;\r
736    pointer_type m_pointer;\r
737    value_type m_char;\r
738    const match_results_type m_cresults;\r
739    OutIterator m_out;\r
740    BidiIterator m_in;\r
741    global_regex_namespace::regex_constants::match_flag_type m_mft;\r
742    global_regex_namespace::match_results<typename string_type::const_iterator> m_smatch;\r
743 \r
744    RegexConcept();\r
745    RegexConcept(const RegexConcept&);\r
746    RegexConcept& operator=(const RegexConcept&);\r
747 };\r
748 \r
749 #ifndef BOOST_REGEX_TEST_STD\r
750 //\r
751 // BoostRegexConcept:\r
752 // Test every interface in the Boost implementation:\r
753 //\r
754 template <class Regex>\r
755 struct BoostRegexConcept\r
756 {\r
757    typedef typename Regex::value_type value_type;\r
758    typedef typename Regex::size_type size_type;\r
759    typedef typename Regex::flag_type flag_type;\r
760    typedef typename Regex::locale_type locale_type;\r
761 \r
762    // derived test types:\r
763    typedef const value_type* pointer_type;\r
764    typedef std::basic_string<value_type> string_type;\r
765    typedef typename Regex::const_iterator const_iterator;\r
766    typedef bidirectional_iterator_archetype<value_type> BidiIterator;\r
767    typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;\r
768    typedef global_regex_namespace::match_results<BidiIterator> match_results_type;\r
769 \r
770    void constraints() \r
771    {\r
772       global_regex_namespace::regex_constants::match_flag_type mopts\r
773          = global_regex_namespace::regex_constants::match_default\r
774          | global_regex_namespace::regex_constants::match_not_bol\r
775          | global_regex_namespace::regex_constants::match_not_eol\r
776          | global_regex_namespace::regex_constants::match_not_bow\r
777          | global_regex_namespace::regex_constants::match_not_eow\r
778          | global_regex_namespace::regex_constants::match_any\r
779          | global_regex_namespace::regex_constants::match_not_null\r
780          | global_regex_namespace::regex_constants::match_continuous\r
781          | global_regex_namespace::regex_constants::match_partial\r
782          | global_regex_namespace::regex_constants::match_prev_avail\r
783          | global_regex_namespace::regex_constants::format_default\r
784          | global_regex_namespace::regex_constants::format_sed\r
785          | global_regex_namespace::regex_constants::format_perl\r
786          | global_regex_namespace::regex_constants::format_no_copy\r
787          | global_regex_namespace::regex_constants::format_first_only;\r
788 \r
789       (void)mopts;\r
790 \r
791       function_requires<RegexConcept<Regex> >();\r
792       const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate);\r
793       std::ptrdiff_t pt = except.position();\r
794       ignore_unused_variable_warning(pt);\r
795       const Regex ce, ce2;\r
796 #ifndef BOOST_NO_STD_LOCALE\r
797       m_stream << ce;\r
798 #endif\r
799       unsigned i = ce.error_code();\r
800       ignore_unused_variable_warning(i);\r
801       pointer_type p = ce.expression();\r
802       ignore_unused_variable_warning(p);\r
803       int i2 = ce.compare(ce2);\r
804       ignore_unused_variable_warning(i2);\r
805       bool b = ce == ce2;\r
806       ignore_unused_variable_warning(b);\r
807       b = ce.empty();\r
808       ignore_unused_variable_warning(b);\r
809       b = ce != ce2;\r
810       ignore_unused_variable_warning(b);\r
811       b = ce < ce2;\r
812       ignore_unused_variable_warning(b);\r
813       b = ce > ce2;\r
814       ignore_unused_variable_warning(b);\r
815       b = ce <= ce2;\r
816       ignore_unused_variable_warning(b);\r
817       b = ce >= ce2;\r
818       ignore_unused_variable_warning(b);\r
819       i = ce.status();\r
820       ignore_unused_variable_warning(i);\r
821       size_type s = ce.max_size();\r
822       ignore_unused_variable_warning(s);\r
823       s = ce.size();\r
824       ignore_unused_variable_warning(s);\r
825       const_iterator pi = ce.begin();\r
826       ignore_unused_variable_warning(pi);\r
827       pi = ce.end();\r
828       ignore_unused_variable_warning(pi);\r
829       string_type s2 = ce.str();\r
830       ignore_unused_variable_warning(s2);\r
831 \r
832       m_string = m_sub + m_sub;\r
833       ignore_unused_variable_warning(m_string);\r
834       m_string = m_sub + m_pointer;\r
835       ignore_unused_variable_warning(m_string);\r
836       m_string = m_pointer + m_sub;\r
837       ignore_unused_variable_warning(m_string);\r
838       m_string = m_sub + m_string;\r
839       ignore_unused_variable_warning(m_string);\r
840       m_string = m_string + m_sub;\r
841       ignore_unused_variable_warning(m_string);\r
842       m_string = m_sub + m_char;\r
843       ignore_unused_variable_warning(m_string);\r
844       m_string = m_char + m_sub;\r
845       ignore_unused_variable_warning(m_string);\r
846 \r
847       // Named sub-expressions:\r
848       m_sub = m_cresults[&m_char];\r
849       ignore_unused_variable_warning(m_sub);\r
850       m_sub = m_cresults[m_string];\r
851       ignore_unused_variable_warning(m_sub);\r
852       m_sub = m_cresults[""];\r
853       ignore_unused_variable_warning(m_sub);\r
854       m_sub = m_cresults[std::string("")];\r
855       ignore_unused_variable_warning(m_sub);\r
856       m_string = m_cresults.str(&m_char);\r
857       ignore_unused_variable_warning(m_string);\r
858       m_string = m_cresults.str(m_string);\r
859       ignore_unused_variable_warning(m_string);\r
860       m_string = m_cresults.str("");\r
861       ignore_unused_variable_warning(m_string);\r
862       m_string = m_cresults.str(std::string(""));\r
863       ignore_unused_variable_warning(m_string);\r
864 \r
865       typename match_results_type::difference_type diff;\r
866       diff = m_cresults.length(&m_char);\r
867       ignore_unused_variable_warning(diff);\r
868       diff = m_cresults.length(m_string);\r
869       ignore_unused_variable_warning(diff);\r
870       diff = m_cresults.length("");\r
871       ignore_unused_variable_warning(diff);\r
872       diff = m_cresults.length(std::string(""));\r
873       ignore_unused_variable_warning(diff);\r
874       diff = m_cresults.position(&m_char);\r
875       ignore_unused_variable_warning(diff);\r
876       diff = m_cresults.position(m_string);\r
877       ignore_unused_variable_warning(diff);\r
878       diff = m_cresults.position("");\r
879       ignore_unused_variable_warning(diff);\r
880       diff = m_cresults.position(std::string(""));\r
881       ignore_unused_variable_warning(diff);\r
882 \r
883 #ifndef BOOST_NO_STD_LOCALE\r
884       m_stream << m_sub;\r
885       m_stream << m_cresults;\r
886 #endif\r
887    }\r
888 \r
889    std::basic_ostream<value_type> m_stream;\r
890    sub_match_type m_sub;\r
891    pointer_type m_pointer;\r
892    string_type m_string;\r
893    const value_type m_char;\r
894    match_results_type m_results;\r
895    const match_results_type m_cresults;\r
896 \r
897    BoostRegexConcept();\r
898    BoostRegexConcept(const BoostRegexConcept&);\r
899    BoostRegexConcept& operator=(const BoostRegexConcept&);\r
900 };\r
901 \r
902 #endif // BOOST_REGEX_TEST_STD\r
903 \r
904 }\r
905 \r
906 #endif\r