We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5a30fc8 commit d2a7527Copy full SHA for d2a7527
tests/cnttp.cpp
@@ -1,21 +1,19 @@
1
#include <iostream>
2
#include <ctre.hpp>
3
#include <string_view>
4
-#include <optional>
5
+struct name { bool has; std::string_view first, family; };
6
7
-struct name { std::string_view first, family; };
8
-
9
-std::optional<name> extract(std::string_view sv) noexcept {
+name extract(std::string_view sv) noexcept {
10
#if __cpp_nontype_template_parameter_class
11
if (auto [re,f,l] = ctre::match<"([A-Za-z]+?),([A-Za-z]+?)">(sv); re) {
12
#else
13
using namespace ctre::literals;
14
if (auto [re,f,l] = "([A-Za-z]+?),([A-Za-z]+?)"_ctre.match(sv); re) {
15
#endif
16
- return name{f,l};
+ return name{true, f,l};
17
} else {
18
- return std::nullopt;
+ return name{false, std::string_view(), std::string_view()};
19
}
20
21
0 commit comments