File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 1
1
#include < iostream>
2
2
#include < ctre.hpp>
3
3
#include < string_view>
4
- #include < optional>
5
4
5
+ struct name { bool has; std::string_view first, family; };
6
6
7
- struct name { std::string_view first, family; };
8
-
9
- std::optional<name> extract (std::string_view sv) noexcept {
7
+ name extract (std::string_view sv) noexcept {
10
8
#if __cpp_nontype_template_parameter_class
11
9
if (auto [re,f,l] = ctre::match<" ([A-Za-z]+?),([A-Za-z]+?)" >(sv); re) {
12
10
#else
13
11
using namespace ctre ::literals;
14
12
if (auto [re,f,l] = " ([A-Za-z]+?),([A-Za-z]+?)" _ctre.match (sv); re) {
15
13
#endif
16
- return name{f,l};
14
+ return name{true , f,l};
17
15
} else {
18
- return std::nullopt ;
16
+ return name{ false , std::string_view (), std::string_view ()} ;
19
17
}
20
18
}
21
19
You can’t perform that action at this time.
0 commit comments