| 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 |
|
| 9 |
// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 |
// UNSUPPORTED: no-localization |
| 11 |
|
| 12 |
// Check LWG-3698: `regex_iterator` and `join_view` don't work together very well |
| 13 |
|
| 14 |
#include <algorithm> |
| 15 |
#include <array> |
| 16 |
#include <cassert> |
| 17 |
#include <ranges> |
| 18 |
#include <regex> |
| 19 |
#include <string_view> |
| 20 |
|
| 21 |
int main(int, char**) { |
| 22 |
char const text[] = "Hello"; |
| 23 |
std::regex regex{"[a-z]"}; |
| 24 |
|
| 25 |
auto lower = |
| 26 |
std::ranges::subrange( |
| 27 |
std::cregex_iterator(std::ranges::begin(text), std::ranges::end(text), regex), std::cregex_iterator{}) | |
| 28 |
std::views::join | std::views::transform([](auto const& sm) { return std::string_view(sm.first, sm.second); }); |
| 29 |
|
| 30 |
assert(std::ranges::equal(lower, std::to_array<std::string_view>({"e", "l", "l", "o"}))); |
| 31 |
|
| 32 |
return 0; |
| 33 |
} |