iter_iter.pass.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <regex>
  9. // template <class charT, class traits = regex_traits<charT>> class basic_regex;
  10. // template <class ForwardIterator>
  11. // basic_regex(ForwardIterator first, ForwardIterator last);
  12. #include <regex>
  13. #include <cassert>
  14. #include "test_iterators.h"
  15. #include "test_macros.h"
  16. template <class Iter>
  17. void
  18. test(Iter first, Iter last, unsigned mc)
  19. {
  20. std::basic_regex<typename std::iterator_traits<Iter>::value_type> r(first, last);
  21. assert(r.flags() == std::regex_constants::ECMAScript);
  22. assert(r.mark_count() == mc);
  23. }
  24. int main(int, char**)
  25. {
  26. typedef forward_iterator<std::string::const_iterator> F;
  27. std::string s1("\\(a\\)");
  28. std::string s2("\\(a[bc]\\)");
  29. std::string s3("\\(a\\([bc]\\)\\)");
  30. std::string s4("(a([bc]))");
  31. test(F(s1.begin()), F(s1.end()), 0);
  32. test(F(s2.begin()), F(s2.end()), 0);
  33. test(F(s3.begin()), F(s3.end()), 0);
  34. test(F(s4.begin()), F(s4.end()), 2);
  35. return 0;
  36. }