File: msvc.cpp

package info (click to toggle)
ctre 3.9.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,084 kB
  • sloc: cpp: 80,452; makefile: 135; javascript: 69; python: 31
file content (41 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <ctre.hpp>
#include <string_view>

void empty_symbol() { }

using namespace std::string_view_literals;

static inline constexpr auto pattern1 = ctll::fixed_string{"^[\\x30-\\x39]+?$"};
static inline constexpr auto pattern2 = ctll::fixed_string{""};


static_assert(ctre::re<pattern1>().match("123456789"sv));
static_assert(ctre::re<pattern2>().match(""sv));

template <auto & ptn> constexpr bool re() {
#if CTRE_CNTTP_COMPILER_CHECK
	constexpr auto _ptn = ptn;
#else
	constexpr auto & _ptn = ptn;
#endif
	return ctll::parser<ctre::pcre, _ptn, ctre::pcre_actions>::template correct_with<ctre::pcre_context<>>;
}

static_assert(re<pattern2>());

static inline constexpr ctll::fixed_string pat = "hello";

template <auto & ptn> constexpr bool re2() {
#if CTRE_CNTTP_COMPILER_CHECK
	constexpr auto _ptn = ptn;
#else
	constexpr auto & _ptn = ptn;
#endif
	return ctll::parser<ctre::pcre, _ptn, ctre::pcre_actions>::template correct_with<ctre::pcre_context<>>;
}

static_assert(re<pat>());

static_assert(ctre::re<pat>().match("hello"sv));

static_assert(ctre::match<pat>("hello"sv));