Home | History | Annotate | Download | only in re.alg.search
      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 Allocator, class charT, class traits>
     13 //     bool
     14 //     regex_search(BidirectionalIterator first, BidirectionalIterator last,
     15 //                  match_results<BidirectionalIterator, Allocator>& m,
     16 //                  const basic_regex<charT, traits>& e,
     17 //                  regex_constants::match_flag_type flags = regex_constants::match_default);
     18 
     19 #include <regex>
     20 #include <cassert>
     21 #include "test_macros.h"
     22 
     23 int main()
     24 {
     25     // Iterating over /^a/ should yield one instance at the beginning
     26     // of the text.
     27 
     28     const char *text = "aaa\naa";
     29     std::regex re("^a");
     30     std::cregex_iterator it(text, text+6, re);
     31     std::cregex_iterator end = std::cregex_iterator();
     32 
     33     assert(it->str() == "a");
     34     assert(it->position(0) == 0);
     35     assert(it->length(0) == 1);
     36 
     37     ++it;
     38     assert(it == end);
     39 }
     40