os/ossrv/ossrv_pub/boost_apis/boost/regex/concepts.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 size_type 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       size_type 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       bool b = ce.empty();
   372       ignore_unused_variable_warning(b);
   373       size_type i = ce.mark_count();
   374       ignore_unused_variable_warning(i);
   375       m_flags = ce.flags();
   376       e.imbue(ce.getloc());
   377       e.swap(e1);
   378       
   379       global_regex_namespace::swap(e, e1);
   380 
   381       // sub_match:
   382       BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::pair<BidiIterator, BidiIterator>, sub_match_type>::value));
   383       typedef typename sub_match_type::value_type sub_value_type;
   384       typedef typename sub_match_type::difference_type sub_diff_type;
   385       typedef typename sub_match_type::iterator sub_iter_type;
   386       BOOST_STATIC_ASSERT((::boost::is_same<sub_value_type, value_type>::value));
   387       BOOST_STATIC_ASSERT((::boost::is_same<sub_iter_type, BidiIterator>::value));
   388       b = m_sub.matched;
   389       ignore_unused_variable_warning(b);
   390       BidiIterator bi = m_sub.first;
   391       ignore_unused_variable_warning(bi);
   392       bi = m_sub.second;
   393       ignore_unused_variable_warning(bi);
   394       sub_diff_type diff = m_sub.length();
   395       ignore_unused_variable_warning(diff);
   396       // match_results tests:
   397       typedef typename match_results_type::value_type mr_value_type;
   398       typedef typename match_results_type::const_reference mr_const_reference;
   399       typedef typename match_results_type::reference mr_reference;
   400       typedef typename match_results_type::const_iterator mr_const_iterator;
   401       typedef typename match_results_type::iterator mr_iterator;
   402       typedef typename match_results_type::difference_type mr_difference_type;
   403       typedef typename match_results_type::size_type mr_size_type;
   404       typedef typename match_results_type::allocator_type mr_allocator_type;
   405       typedef typename match_results_type::char_type mr_char_type;
   406       typedef typename match_results_type::string_type mr_string_type;
   407 
   408       match_results_type m1;
   409       mr_allocator_type at;
   410       match_results_type m2(at);
   411       match_results_type m3(m1);
   412       m1 = m2;
   413 
   414       int ival = 0;
   415 
   416       mr_size_type mrs = m_cresults.size();
   417       ignore_unused_variable_warning(mrs);
   418       mrs = m_cresults.max_size();
   419       ignore_unused_variable_warning(mrs);
   420       b = m_cresults.empty();
   421       ignore_unused_variable_warning(b);
   422       mr_difference_type mrd = m_cresults.length();
   423       ignore_unused_variable_warning(mrd);
   424       mrd = m_cresults.length(ival);
   425       ignore_unused_variable_warning(mrd);
   426       mrd = m_cresults.position();
   427       ignore_unused_variable_warning(mrd);
   428       mrd = m_cresults.position(mrs);
   429       ignore_unused_variable_warning(mrd);
   430 
   431       mr_const_reference mrcr = m_cresults[ival];
   432       ignore_unused_variable_warning(mrcr);
   433       mr_const_reference mrcr2 = m_cresults.prefix();
   434       ignore_unused_variable_warning(mrcr2);
   435       mr_const_reference mrcr3 = m_cresults.suffix();
   436       ignore_unused_variable_warning(mrcr3);
   437       mr_const_iterator mrci = m_cresults.begin();
   438       ignore_unused_variable_warning(mrci);
   439       mrci = m_cresults.end();
   440       ignore_unused_variable_warning(mrci);
   441 
   442       mr_allocator_type at2 = m_cresults.get_allocator();
   443       m_results.swap(m_results);
   444       global_regex_namespace::swap(m_results, m_results);
   445 
   446       // regex_match:
   447       b = global_regex_namespace::regex_match(m_in, m_in, m_results, e);
   448       ignore_unused_variable_warning(b);
   449       b = global_regex_namespace::regex_match(m_in, m_in, m_results, e, m_mft);
   450       ignore_unused_variable_warning(b);
   451       b = global_regex_namespace::regex_match(m_in, m_in, e);
   452       ignore_unused_variable_warning(b);
   453       b = global_regex_namespace::regex_match(m_in, m_in, e, m_mft);
   454       ignore_unused_variable_warning(b);
   455       b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e);
   456       ignore_unused_variable_warning(b);
   457       b = global_regex_namespace::regex_match(m_pointer, m_pmatch, e, m_mft);
   458       ignore_unused_variable_warning(b);
   459       b = global_regex_namespace::regex_match(m_pointer, e);
   460       ignore_unused_variable_warning(b);
   461       b = global_regex_namespace::regex_match(m_pointer, e, m_mft);
   462       ignore_unused_variable_warning(b);
   463       // regex_search:
   464       b = global_regex_namespace::regex_search(m_in, m_in, m_results, e);
   465       ignore_unused_variable_warning(b);
   466       b = global_regex_namespace::regex_search(m_in, m_in, m_results, e, m_mft);
   467       ignore_unused_variable_warning(b);
   468       b = global_regex_namespace::regex_search(m_in, m_in, e);
   469       ignore_unused_variable_warning(b);
   470       b = global_regex_namespace::regex_search(m_in, m_in, e, m_mft);
   471       ignore_unused_variable_warning(b);
   472       b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e);
   473       ignore_unused_variable_warning(b);
   474       b = global_regex_namespace::regex_search(m_pointer, m_pmatch, e, m_mft);
   475       ignore_unused_variable_warning(b);
   476       b = global_regex_namespace::regex_search(m_pointer, e);
   477       ignore_unused_variable_warning(b);
   478       b = global_regex_namespace::regex_search(m_pointer, e, m_mft);
   479       ignore_unused_variable_warning(b);
   480 
   481       // regex_iterator:
   482       typedef typename regex_iterator_type::regex_type rit_regex_type;
   483       typedef typename regex_iterator_type::value_type rit_value_type;
   484       typedef typename regex_iterator_type::difference_type rit_difference_type;
   485       typedef typename regex_iterator_type::pointer rit_pointer;
   486       typedef typename regex_iterator_type::reference rit_reference;
   487       typedef typename regex_iterator_type::iterator_category rit_iterator_category;
   488       BOOST_STATIC_ASSERT((::boost::is_same<rit_regex_type, Regex>::value));
   489       BOOST_STATIC_ASSERT((::boost::is_same<rit_value_type, match_results_type>::value));
   490       BOOST_STATIC_ASSERT((::boost::is_same<rit_difference_type, std::ptrdiff_t>::value));
   491       BOOST_STATIC_ASSERT((::boost::is_same<rit_pointer, const match_results_type*>::value));
   492       BOOST_STATIC_ASSERT((::boost::is_same<rit_reference, const match_results_type&>::value));
   493       BOOST_STATIC_ASSERT((::boost::is_convertible<rit_iterator_category*, std::forward_iterator_tag*>::value));
   494       // this takes care of most of the checks needed:
   495       function_requires<ForwardIteratorConcept<regex_iterator_type> >();
   496       regex_iterator_type iter1(m_in, m_in, e);
   497       ignore_unused_variable_warning(iter1);
   498       regex_iterator_type iter2(m_in, m_in, e, m_mft);
   499       ignore_unused_variable_warning(iter2);
   500 
   501       // regex_token_iterator:
   502       typedef typename regex_token_iterator_type::regex_type rtit_regex_type;
   503       typedef typename regex_token_iterator_type::value_type rtit_value_type;
   504       typedef typename regex_token_iterator_type::difference_type rtit_difference_type;
   505       typedef typename regex_token_iterator_type::pointer rtit_pointer;
   506       typedef typename regex_token_iterator_type::reference rtit_reference;
   507       typedef typename regex_token_iterator_type::iterator_category rtit_iterator_category;
   508       BOOST_STATIC_ASSERT((::boost::is_same<rtit_regex_type, Regex>::value));
   509       BOOST_STATIC_ASSERT((::boost::is_same<rtit_value_type, sub_match_type>::value));
   510       BOOST_STATIC_ASSERT((::boost::is_same<rtit_difference_type, std::ptrdiff_t>::value));
   511       BOOST_STATIC_ASSERT((::boost::is_same<rtit_pointer, const sub_match_type*>::value));
   512       BOOST_STATIC_ASSERT((::boost::is_same<rtit_reference, const sub_match_type&>::value));
   513       BOOST_STATIC_ASSERT((::boost::is_convertible<rtit_iterator_category*, std::forward_iterator_tag*>::value));
   514       // this takes care of most of the checks needed:
   515       function_requires<ForwardIteratorConcept<regex_token_iterator_type> >();
   516       regex_token_iterator_type ti1(m_in, m_in, e);
   517       ignore_unused_variable_warning(ti1);
   518       regex_token_iterator_type ti2(m_in, m_in, e, 0);
   519       ignore_unused_variable_warning(ti2);
   520       regex_token_iterator_type ti3(m_in, m_in, e, 0, m_mft);
   521       ignore_unused_variable_warning(ti3);
   522       std::vector<int> subs;
   523       regex_token_iterator_type ti4(m_in, m_in, e, subs);
   524       ignore_unused_variable_warning(ti4);
   525       regex_token_iterator_type ti5(m_in, m_in, e, subs, m_mft);
   526       ignore_unused_variable_warning(ti5);
   527       static const int i_array[3] = { 1, 2, 3, };
   528       regex_token_iterator_type ti6(m_in, m_in, e, i_array);
   529       ignore_unused_variable_warning(ti6);
   530       regex_token_iterator_type ti7(m_in, m_in, e, i_array, m_mft);
   531       ignore_unused_variable_warning(ti7);
   532    }
   533 
   534    pointer_type m_pointer;
   535    flag_type m_flags;
   536    size_type m_size;
   537    input_iterator_type in1, in2;
   538    const sub_match_type m_sub;
   539    const value_type m_char;
   540    match_results_type m_results;
   541    const match_results_type m_cresults;
   542    OutIterator m_out;
   543    BidiIterator m_in;
   544    global_regex_namespace::regex_constants::match_flag_type m_mft;
   545    global_regex_namespace::match_results<pointer_type> m_pmatch;
   546 
   547    BaseRegexConcept();
   548    BaseRegexConcept(const BaseRegexConcept&);
   549    BaseRegexConcept& operator=(const BaseRegexConcept&);
   550 };
   551 
   552 //
   553 // RegexConcept:
   554 // Test every interface in the std:
   555 //
   556 template <class Regex>
   557 struct RegexConcept
   558 {
   559    typedef typename Regex::value_type value_type;
   560    typedef typename Regex::size_type size_type;
   561    typedef typename Regex::flag_type flag_type;
   562    typedef typename Regex::locale_type locale_type;
   563 
   564    // derived test types:
   565    typedef const value_type* pointer_type;
   566    typedef std::basic_string<value_type> string_type;
   567    typedef boost::bidirectional_iterator_archetype<value_type> BidiIterator;
   568    typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
   569    typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
   570    typedef output_iterator_archetype<value_type> OutIterator;
   571 
   572 
   573    void constraints() 
   574    {
   575       function_requires<BaseRegexConcept<Regex> >();
   576       // string based construct:
   577       Regex e1(m_string);
   578       ignore_unused_variable_warning(e1);
   579       Regex e2(m_string, m_flags);
   580       ignore_unused_variable_warning(e2);
   581 
   582       // assign etc:
   583       Regex e;
   584       e = m_string;
   585       e.assign(m_string);
   586       e.assign(m_string, m_flags);
   587 
   588       // sub_match:
   589       string_type s(m_sub);
   590       ignore_unused_variable_warning(s);
   591       s = m_sub.str();
   592       ignore_unused_variable_warning(s);
   593       int i = m_sub.compare(m_string);
   594       ignore_unused_variable_warning(i);
   595 
   596       int i2 = m_sub.compare(m_sub);
   597       ignore_unused_variable_warning(i2);
   598       i2 = m_sub.compare(m_pointer);
   599       ignore_unused_variable_warning(i2);
   600 
   601       bool 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       b = m_sub >= m_sub;
   612       ignore_unused_variable_warning(b);
   613 
   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       b = m_sub >= m_pointer;
   625       ignore_unused_variable_warning(b);
   626 
   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       b = m_pointer >= m_sub;
   638       ignore_unused_variable_warning(b);
   639 
   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       b = m_sub >= m_char;
   651       ignore_unused_variable_warning(b);
   652 
   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       b = m_char >= m_sub;
   664       ignore_unused_variable_warning(b);
   665 
   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       b = m_sub >= m_string;
   677       ignore_unused_variable_warning(b);
   678 
   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       b = m_string >= m_sub;
   690       ignore_unused_variable_warning(b);
   691 
   692       // match results:
   693       m_string = m_results.str();
   694       ignore_unused_variable_warning(m_string);
   695       m_string = m_results.str(0);
   696       ignore_unused_variable_warning(m_string);
   697       m_out = m_cresults.format(m_out, m_string);
   698       m_out = m_cresults.format(m_out, m_string, m_mft);
   699       m_string = m_cresults.format(m_string);
   700       ignore_unused_variable_warning(m_string);
   701       m_string = m_cresults.format(m_string, m_mft);
   702       ignore_unused_variable_warning(m_string);
   703 
   704       // regex_match:
   705       b = global_regex_namespace::regex_match(m_string, m_smatch, e);
   706       ignore_unused_variable_warning(b);
   707       b = global_regex_namespace::regex_match(m_string, m_smatch, e, m_mft);
   708       ignore_unused_variable_warning(b);
   709       b = global_regex_namespace::regex_match(m_string, e);
   710       ignore_unused_variable_warning(b);
   711       b = global_regex_namespace::regex_match(m_string, e, m_mft);
   712       ignore_unused_variable_warning(b);
   713 
   714       // regex_search:
   715       b = global_regex_namespace::regex_search(m_string, m_smatch, e);
   716       ignore_unused_variable_warning(b);
   717       b = global_regex_namespace::regex_search(m_string, m_smatch, e, m_mft);
   718       ignore_unused_variable_warning(b);
   719       b = global_regex_namespace::regex_search(m_string, e);
   720       ignore_unused_variable_warning(b);
   721       b = global_regex_namespace::regex_search(m_string, e, m_mft);
   722       ignore_unused_variable_warning(b);
   723 
   724       // regex_replace:
   725       m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string, m_mft);
   726       m_out = global_regex_namespace::regex_replace(m_out, m_in, m_in, e, m_string);
   727       m_string = global_regex_namespace::regex_replace(m_string, e, m_string, m_mft);
   728       ignore_unused_variable_warning(m_string);
   729       m_string = global_regex_namespace::regex_replace(m_string, e, m_string);
   730       ignore_unused_variable_warning(m_string);
   731 
   732    }
   733 
   734    flag_type m_flags;
   735    string_type m_string;
   736    const sub_match_type m_sub;
   737    match_results_type m_results;
   738    pointer_type m_pointer;
   739    value_type m_char;
   740    const match_results_type m_cresults;
   741    OutIterator m_out;
   742    BidiIterator m_in;
   743    global_regex_namespace::regex_constants::match_flag_type m_mft;
   744    global_regex_namespace::match_results<typename string_type::const_iterator> m_smatch;
   745 
   746    RegexConcept();
   747    RegexConcept(const RegexConcept&);
   748    RegexConcept& operator=(const RegexConcept&);
   749 };
   750 
   751 #ifndef BOOST_REGEX_TEST_STD
   752 //
   753 // BoostRegexConcept:
   754 // Test every interface in the Boost implementation:
   755 //
   756 template <class Regex>
   757 struct BoostRegexConcept
   758 {
   759    typedef typename Regex::value_type value_type;
   760    typedef typename Regex::size_type size_type;
   761    typedef typename Regex::flag_type flag_type;
   762    typedef typename Regex::locale_type locale_type;
   763 
   764    // derived test types:
   765    typedef const value_type* pointer_type;
   766    typedef std::basic_string<value_type> string_type;
   767    typedef typename Regex::const_iterator const_iterator;
   768    typedef bidirectional_iterator_archetype<value_type> BidiIterator;
   769    typedef global_regex_namespace::sub_match<BidiIterator> sub_match_type;
   770    typedef global_regex_namespace::match_results<BidiIterator> match_results_type;
   771 
   772    void constraints() 
   773    {
   774       global_regex_namespace::regex_constants::match_flag_type mopts
   775          = global_regex_namespace::regex_constants::match_default
   776          | global_regex_namespace::regex_constants::match_not_bol
   777          | global_regex_namespace::regex_constants::match_not_eol
   778          | global_regex_namespace::regex_constants::match_not_bow
   779          | global_regex_namespace::regex_constants::match_not_eow
   780          | global_regex_namespace::regex_constants::match_any
   781          | global_regex_namespace::regex_constants::match_not_null
   782          | global_regex_namespace::regex_constants::match_continuous
   783          | global_regex_namespace::regex_constants::match_partial
   784          | global_regex_namespace::regex_constants::match_prev_avail
   785          | global_regex_namespace::regex_constants::format_default
   786          | global_regex_namespace::regex_constants::format_sed
   787          | global_regex_namespace::regex_constants::format_perl
   788          | global_regex_namespace::regex_constants::format_no_copy
   789          | global_regex_namespace::regex_constants::format_first_only;
   790 
   791       (void)mopts;
   792 
   793       function_requires<RegexConcept<Regex> >();
   794       const global_regex_namespace::regex_error except(global_regex_namespace::regex_constants::error_collate);
   795       std::ptrdiff_t pt = except.position();
   796       ignore_unused_variable_warning(pt);
   797       const Regex ce, ce2;
   798 #ifndef BOOST_NO_STD_LOCALE
   799       m_stream << ce;
   800 #endif
   801       unsigned i = ce.error_code();
   802       ignore_unused_variable_warning(i);
   803       pointer_type p = ce.expression();
   804       ignore_unused_variable_warning(p);
   805       int i2 = ce.compare(ce2);
   806       ignore_unused_variable_warning(i2);
   807       bool b = ce == ce2;
   808       ignore_unused_variable_warning(b);
   809       b = ce != ce2;
   810       ignore_unused_variable_warning(b);
   811       b = ce < ce2;
   812       ignore_unused_variable_warning(b);
   813       b = ce > ce2;
   814       ignore_unused_variable_warning(b);
   815       b = ce <= ce2;
   816       ignore_unused_variable_warning(b);
   817       b = ce >= ce2;
   818       ignore_unused_variable_warning(b);
   819       i = ce.status();
   820       ignore_unused_variable_warning(i);
   821       size_type s = ce.max_size();
   822       ignore_unused_variable_warning(s);
   823       s = ce.size();
   824       ignore_unused_variable_warning(s);
   825       const_iterator pi = ce.begin();
   826       ignore_unused_variable_warning(pi);
   827       pi = ce.end();
   828       ignore_unused_variable_warning(pi);
   829       string_type s2 = ce.str();
   830       ignore_unused_variable_warning(s2);
   831 
   832       m_string = m_sub + m_sub;
   833       ignore_unused_variable_warning(m_string);
   834       m_string = m_sub + m_pointer;
   835       ignore_unused_variable_warning(m_string);
   836       m_string = m_pointer + m_sub;
   837       ignore_unused_variable_warning(m_string);
   838       m_string = m_sub + m_string;
   839       ignore_unused_variable_warning(m_string);
   840       m_string = m_string + m_sub;
   841       ignore_unused_variable_warning(m_string);
   842       m_string = m_sub + m_char;
   843       ignore_unused_variable_warning(m_string);
   844       m_string = m_char + m_sub;
   845       ignore_unused_variable_warning(m_string);
   846 
   847 #ifndef BOOST_NO_STD_LOCALE
   848       m_stream << m_sub;
   849       m_stream << m_cresults;
   850 #endif
   851    }
   852 
   853    std::basic_ostream<value_type> m_stream;
   854    sub_match_type m_sub;
   855    pointer_type m_pointer;
   856    string_type m_string;
   857    const value_type m_char;
   858    match_results_type m_results;
   859    const match_results_type m_cresults;
   860 
   861    BoostRegexConcept();
   862    BoostRegexConcept(const BoostRegexConcept&);
   863    BoostRegexConcept& operator=(const BoostRegexConcept&);
   864 };
   865 
   866 #endif // BOOST_REGEX_TEST_STD
   867 
   868 }
   869 
   870 #endif