Home | History | Annotate | Download | only in re.submatch.members
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <regex>
     11 
     12 // template <class BidirectionalIterator> class sub_match;
     13 
     14 // difference_type length() const;
     15 
     16 #include <regex>
     17 #include <cassert>
     18 #include "test_macros.h"
     19 
     20 int main()
     21 {
     22     {
     23         typedef char CharT;
     24         typedef std::sub_match<const CharT*> SM;
     25         SM sm = SM();
     26         assert(sm.length() == 0);
     27         const CharT s[] = {'1', '2', '3', 0};
     28         sm.first = s;
     29         sm.second = s + 3;
     30         sm.matched = true;
     31         assert(sm.length() == 3);
     32     }
     33     {
     34         typedef wchar_t CharT;
     35         typedef std::sub_match<const CharT*> SM;
     36         SM sm = SM();
     37         assert(sm.length() == 0);
     38         const CharT s[] = {'1', '2', '3', 0};
     39         sm.first = s;
     40         sm.second = s + 3;
     41         sm.matched = true;
     42         assert(sm.length() == 3);
     43     }
     44 }
     45