#include <regex>
#include <string>
#include <iterator>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
#include "test_iterators.h"
#include "test_allocator.h"
using namespace std::literals;
struct A {};
int main(int, char**)
{
{
std::string s1("\\(a\\)");
std::basic_regex re(s1.begin(), s1.end());
static_assert(std::is_same_v<decltype(re), std::basic_regex<char>>, "");
assert(re.flags() == std::regex_constants::ECMAScript);
assert(re.mark_count() == 0);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::wstring s1(L"\\(a\\)");
std::basic_regex re(s1.begin(), s1.end(), std::regex_constants::basic);
static_assert(std::is_same_v<decltype(re), std::basic_regex<wchar_t>>, "");
assert(re.flags() == std::regex_constants::basic);
assert(re.mark_count() == 1);
}
#endif
{
std::basic_regex re("(a([bc]))"s);
static_assert(std::is_same_v<decltype(re), std::basic_regex<char>>, "");
assert(re.flags() == std::regex_constants::ECMAScript);
assert(re.mark_count() == 2);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_regex re(L"(a([bc]))"s, std::regex_constants::awk);
static_assert(std::is_same_v<decltype(re), std::basic_regex<wchar_t>>, "");
assert(re.flags() == std::regex_constants::awk);
assert(re.mark_count() == 2);
}
#endif
{
std::basic_regex re("ABCDE");
static_assert(std::is_same_v<decltype(re), std::basic_regex<char>>, "");
assert(re.flags() == std::regex_constants::ECMAScript);
assert(re.mark_count() == 0);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_regex re(L"ABCDE", std::regex_constants::grep);
static_assert(std::is_same_v<decltype(re), std::basic_regex<wchar_t>>, "");
assert(re.flags() == std::regex_constants::grep);
assert(re.mark_count() == 0);
}
#endif
{
std::basic_regex re("ABCDEDEF", 7);
static_assert(std::is_same_v<decltype(re), std::basic_regex<char>>, "");
assert(re.flags() == std::regex_constants::ECMAScript);
assert(re.mark_count() == 0);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_regex re(L"ABCDEDEF", 8, std::regex_constants::awk);
static_assert(std::is_same_v<decltype(re), std::basic_regex<wchar_t>>, "");
assert(re.flags() == std::regex_constants::awk);
assert(re.mark_count() == 0);
}
#endif
{
std::basic_regex<char> source;
std::basic_regex re(source);
static_assert(std::is_same_v<decltype(re), std::basic_regex<char>>, "");
assert(re.flags() == source.flags());
assert(re.mark_count() == source.mark_count());
}
{
}
{
std::basic_regex re({'A', 'B', 'F', 'E', 'D'});
static_assert(std::is_same_v<decltype(re), std::basic_regex<char>>, "");
assert(re.flags() == std::regex_constants::ECMAScript);
assert(re.mark_count() == 0);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
{
std::basic_regex re({L'A', L'B', L'F', L'E', L'D'}, std::regex_constants::grep);
static_assert(std::is_same_v<decltype(re), std::basic_regex<wchar_t>>, "");
assert(re.flags() == std::regex_constants::grep);
assert(re.mark_count() == 0);
}
#endif
return 0;
}