summaryrefslogtreecommitdiffstats
path: root/server/src/util.cppm
diff options
context:
space:
mode:
authorRutger Broekhoff2026-08-28 22:17:10 +0200
committerRutger Broekhoff2026-08-28 22:17:10 +0200
commit70643a9e4821bd11c3f363f1708fe420965467d1 (patch)
tree65572b58e247248846628940a2aaca197a15d784 /server/src/util.cppm
parent173cd34bdd0717d3f4beeac76b3296ecd46ada0d (diff)
downloadroutemon-70643a9e4821bd11c3f363f1708fe420965467d1.tar.gz
routemon-70643a9e4821bd11c3f363f1708fe420965467d1.zip
Format again
Diffstat (limited to 'server/src/util.cppm')
-rw-r--r--server/src/util.cppm25
1 files changed, 12 insertions, 13 deletions
diff --git a/server/src/util.cppm b/server/src/util.cppm
index bdccf10..2e20e8b 100644
--- a/server/src/util.cppm
+++ b/server/src/util.cppm
@@ -14,9 +14,9 @@ struct overloaded : Ts...
14}; 14};
15 15
16export constexpr auto parse_double( 16export constexpr auto parse_double(
17 std::string_view s, 17 std::string_view s,
18 std::chars_format fmt = std::chars_format::general) noexcept 18 std::chars_format fmt = std::chars_format::general) noexcept
19 -> std::optional<double> 19 -> std::optional<double>
20{ 20{
21 auto x = 0.0; 21 auto x = 0.0;
22 auto [_, ec] = std::from_chars(s.data(), s.data() + s.size(), x, fmt); 22 auto [_, ec] = std::from_chars(s.data(), s.data() + s.size(), x, fmt);
@@ -31,9 +31,9 @@ export constexpr auto parse_double(
31} 31}
32 32
33export constexpr auto parse_float( 33export constexpr auto parse_float(
34 std::string_view s, 34 std::string_view s,
35 std::chars_format fmt = std::chars_format::general) noexcept 35 std::chars_format fmt = std::chars_format::general) noexcept
36 -> std::optional<float> 36 -> std::optional<float>
37{ 37{
38 auto x = 0.0; 38 auto x = 0.0;
39 auto [_, ec] = std::from_chars(s.data(), s.data() + s.size(), x, fmt); 39 auto [_, ec] = std::from_chars(s.data(), s.data() + s.size(), x, fmt);
@@ -62,7 +62,7 @@ public:
62 static auto nil() -> std::shared_ptr<aolist<T>> { return nullptr; } 62 static auto nil() -> std::shared_ptr<aolist<T>> { return nullptr; }
63 63
64 static auto cons(T v, std::shared_ptr<aolist<T> const> l) 64 static auto cons(T v, std::shared_ptr<aolist<T> const> l)
65 -> std::shared_ptr<aolist<T>> 65 -> std::shared_ptr<aolist<T>>
66 { 66 {
67 return std::shared_ptr<aolist<T>>{new aolist<T>{v, l}}; 67 return std::shared_ptr<aolist<T>>{new aolist<T>{v, l}};
68 } 68 }
@@ -75,8 +75,8 @@ public:
75export constexpr auto size_from_int(int x) -> std::optional<std::size_t> 75export constexpr auto size_from_int(int x) -> std::optional<std::size_t>
76{ 76{
77 static_assert( 77 static_assert(
78 sizeof(int) <= sizeof(std::size_t), 78 sizeof(int) <= sizeof(std::size_t),
79 "cannot cast int to smaller size_t type"); 79 "cannot cast int to smaller size_t type");
80 if (x < 0) 80 if (x < 0)
81 return std::nullopt; 81 return std::nullopt;
82 return static_cast<std::size_t>(x); 82 return static_cast<std::size_t>(x);
@@ -155,8 +155,7 @@ public:
155 { 155 {
156 s_ = rhs.s_; 156 s_ = rhs.s_;
157 length_.store( 157 length_.store(
158 rhs.length_.load(std::memory_order_acquire), 158 rhs.length_.load(std::memory_order_acquire), std::memory_order_release);
159 std::memory_order_release);
160 } 159 }
161 return *this; 160 return *this;
162 } 161 }
@@ -203,7 +202,7 @@ public:
203}; 202};
204 203
205constexpr auto operator""_zsv(char const* s, std::size_t length) noexcept 204constexpr auto operator""_zsv(char const* s, std::size_t length) noexcept
206 -> zstring_view 205 -> zstring_view
207{ 206{
208 return zstring_view{s, length}; 207 return zstring_view{s, length};
209} 208}
@@ -214,7 +213,7 @@ auto operator==(zstring_view lhs, zstring_view rhs) -> bool
214} 213}
215 214
216export constexpr auto split_on(std::string_view s, char c) 215export constexpr auto split_on(std::string_view s, char c)
217 -> std::pair<std::string_view, std::optional<std::string_view>> 216 -> std::pair<std::string_view, std::optional<std::string_view>>
218{ 217{
219 if (auto i = s.find(c); i != std::string_view::npos) 218 if (auto i = s.find(c); i != std::string_view::npos)
220 return std::make_pair(s.substr(0, i), s.substr(i + 1)); 219 return std::make_pair(s.substr(0, i), s.substr(i + 1));