From 4a81c39d94b6877f7753896218467ff77b8d7f6f Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 30 Nov 2026 23:33:26 +0100 Subject: class -> typename --- server/src/config.cpp | 4 ++-- server/src/database/sqlite3.cppm | 6 ++--- server/src/geo/utm_multizonal.cppm | 4 ++-- server/src/http/core/client.cppm | 2 +- server/src/http/core/common.cppm | 10 ++++----- server/src/http/core/server.cppm | 42 +++++++++++++++++------------------ server/src/http/ext/hmac_openssl.cppm | 1 - server/src/http/handler.cpp | 2 +- server/src/locale.cppm | 2 +- server/src/log.cppm | 8 +++---- server/src/time.cppm | 34 ++++++++++++++-------------- server/src/util.cppm | 14 ++++++------ server/src/xml.cppm | 28 +++++++++++------------ 13 files changed, 78 insertions(+), 79 deletions(-) (limited to 'server') diff --git a/server/src/config.cpp b/server/src/config.cpp index ec49aeb..4454781 100644 --- a/server/src/config.cpp +++ b/server/src/config.cpp @@ -80,7 +80,7 @@ public: } } - template + template auto allow_at(std::string_view key) -> std::optional { visited_.emplace(key); @@ -103,7 +103,7 @@ public: } } - template + template auto expect_at(std::string_view key) -> T { if (auto&& mv = allow_at(key); mv) diff --git a/server/src/database/sqlite3.cppm b/server/src/database/sqlite3.cppm index 2216109..61c3257 100644 --- a/server/src/database/sqlite3.cppm +++ b/server/src/database/sqlite3.cppm @@ -12,18 +12,18 @@ extern "C" namespace routemon::database::sqlite3 { -template concept C> +template concept C> concept optional_of = requires { typename T::value_type; requires std::same_as>; requires C; }; -template +template concept scannable_prim = std::same_as || std::same_as || std::same_as; -template +template concept scannable = scannable_prim || optional_of; class mutex_guard diff --git a/server/src/geo/utm_multizonal.cppm b/server/src/geo/utm_multizonal.cppm index 56c6481..8886375 100644 --- a/server/src/geo/utm_multizonal.cppm +++ b/server/src/geo/utm_multizonal.cppm @@ -202,7 +202,7 @@ auto split_linestring_across_zones(utm::zonable_wgs84_linestring ls) return splits; } -template +template class linestring_rtree { public: @@ -265,7 +265,7 @@ public: } }; -template +template class point_rtree { public: diff --git a/server/src/http/core/client.cppm b/server/src/http/core/client.cppm index ada4f03..2bf1137 100644 --- a/server/src/http/core/client.cppm +++ b/server/src/http/core/client.cppm @@ -25,7 +25,7 @@ export class client public: explicit client(net::io_context& ioc); - template + template auto do_request(bhttp::request& req) -> bhttp::response { diff --git a/server/src/http/core/common.cppm b/server/src/http/core/common.cppm index e8fbe42..83d474f 100644 --- a/server/src/http/core/common.cppm +++ b/server/src/http/core/common.cppm @@ -12,23 +12,23 @@ namespace boost::beast { namespace concepts { -template +template concept buffers_generator = beast::is_buffers_generator::value; -template +template concept const_buffer_sequence = beast::is_const_buffer_sequence::value; } // namespace concepts namespace http::concepts { -template +template concept fields = is_fields::value; -template +template concept body = is_body::value; -template +template concept body_reader = is_body_reader::value; } // namespace http::concepts diff --git a/server/src/http/core/server.cppm b/server/src/http/core/server.cppm index dbef975..19eb1c4 100644 --- a/server/src/http/core/server.cppm +++ b/server/src/http/core/server.cppm @@ -146,17 +146,17 @@ public: }; static_assert(beast::concepts::buffers_generator); -template +template using next_handler_t = std::functionnet::awaitable>; -template +template using middleware_t = std::function&, next_handler_t) ->net::awaitable>; -template +template auto id_middleware( Ctx ctx, bhttp::request_header&, next_handler_t next) -> net::awaitable @@ -170,14 +170,14 @@ struct base_ctx trace::id trace_id; }; -template +template using basic_route_handler_fn_t = std::function const& matches) ->net::awaitable>; -template +template auto cors_middleware(std::vector const& allow_origins) -> middleware_t { @@ -199,7 +199,7 @@ auto cors_middleware(std::vector const& allow_origins) }; } -template +template auto expose_trace_id_middleware( Ctx ctx, bhttp::request_header& req_hdr, next_handler_t next) -> net::awaitable @@ -214,7 +214,7 @@ auto expose_trace_id_middleware( co_return std::move(prersp); } -template +template auto expose_content_language_middleware( Ctx ctx, bhttp::request_header& req_hdr, next_handler_t next) -> net::awaitable @@ -297,17 +297,17 @@ auto read_empty_request(base_ctx const& ctx, readable_request&& r) -> net:: co_return r.p->release(); } -template +template struct routed_ctx : InnerCtx { verb_set route_methods; boost::urls::url target; }; -template +template requires requires(Ctx ctx) { // Ctx must be derived from an instantiation of routed_ctx - [](routed_ctx const&) {}(ctx); + [](routed_ctx const&) {}(ctx); } auto default_options_handler( Ctx const& ctx, readable_request r, std::vector const&) @@ -343,7 +343,7 @@ auto default_options_handler( auto global_options_handler(base_ctx const& ctx, readable_request r) -> net::awaitable; -template +template auto middleware_compose(middleware_t ab, middleware_t bc) -> middleware_t { @@ -357,7 +357,7 @@ auto middleware_compose(middleware_t ab, middleware_t bc) }; } -template +template auto middleware_wrap_fn(middleware_t ab, basic_route_handler_fn_t fn) -> basic_route_handler_fn_t { @@ -386,7 +386,7 @@ struct handler_map V post = {}; V put = {}; - template + template auto lookup(this Self&& self, supported_verb v) -> auto&& { switch (v.value) @@ -436,7 +436,7 @@ struct handler_map } }; -template +template struct route_tree { using leaves = handler_map>; @@ -451,7 +451,7 @@ struct route_tree std::variant sub; }; -template +template auto middleware_wrap_tree( middleware_t mw, route_tree const& tree) -> route_tree @@ -479,15 +479,15 @@ auto middleware_wrap_tree( return {.here = new_leaves, .sub = new_sub}; } -template +template concept match_arg = std::constructible_from; -template +template using route_handler_fn_t = std::functionnet::awaitable>; -template +template auto degen_route_handler(route_handler_fn_t fn) -> basic_route_handler_fn_t { @@ -505,10 +505,10 @@ auto degen_route_handler(route_handler_fn_t fn) }; } -template +template struct ctree : route_tree { - template + template auto wrap(middleware_t mw) const -> ctree { @@ -516,7 +516,7 @@ struct ctree : route_tree } }; -template +template struct dtree : handler_map> { [[nodiscard]] auto to_leaves() const -> typename route_tree::leaves diff --git a/server/src/http/ext/hmac_openssl.cppm b/server/src/http/ext/hmac_openssl.cppm index b196094..a175406 100644 --- a/server/src/http/ext/hmac_openssl.cppm +++ b/server/src/http/ext/hmac_openssl.cppm @@ -78,7 +78,6 @@ public: ::EVP_MAC_free(mac_); } - // TODO: move to impl. unit. auto init(boost::optional n, beast::error_code& ec) noexcept -> void { diff --git a/server/src/http/handler.cpp b/server/src/http/handler.cpp index d755c16..580e3f5 100644 --- a/server/src/http/handler.cpp +++ b/server/src/http/handler.cpp @@ -325,7 +325,7 @@ handler::handler( auto handler::make_routes() -> core::route_tree> { - auto handler = [this](MemFn member) + auto handler = [this](MemFn member) { return std::bind_front(member, this); }; return core::dtree>{}.named_subtrees({ diff --git a/server/src/locale.cppm b/server/src/locale.cppm index 00a3d36..43e32c3 100644 --- a/server/src/locale.cppm +++ b/server/src/locale.cppm @@ -20,7 +20,7 @@ using blocale::translate; namespace routemon::locale { -export template +export template concept locale_input_range = std::ranges::input_range && std:: diff --git a/server/src/log.cppm b/server/src/log.cppm index 10c2d7a..22531d0 100644 --- a/server/src/log.cppm +++ b/server/src/log.cppm @@ -48,25 +48,25 @@ public: [[nodiscard]] auto with(std::string const& k, std::string_view v) const -> logger; - template + template auto debug(std::format_string fmt, Args&&... args) -> logger& { return log_at(level::debug, fmt.get(), std::make_format_args(args...)); } - template + template auto info(std::format_string fmt, Args&&... args) -> logger& { return log_at(level::info, fmt.get(), std::make_format_args(args...)); } - template + template auto warn(std::format_string fmt, Args&&... args) -> logger& { return log_at(level::warn, fmt.get(), std::make_format_args(args...)); } - template + template auto error(std::format_string fmt, Args&&... args) -> logger& { return log_at(level::error, fmt.get(), std::make_format_args(args...)); diff --git a/server/src/time.cppm b/server/src/time.cppm index 32df737..61f399b 100644 --- a/server/src/time.cppm +++ b/server/src/time.cppm @@ -4,12 +4,12 @@ import std; export namespace routemon::time { -template +template using timestamp = std::chrono::time_point; auto iso8601_secs(timestamp ts) -> std::string; -template +template class period { // Assuming [start, end). Unfortunately the DATEX II model is not @@ -27,7 +27,7 @@ public: [[nodiscard]] auto end() const -> timestamp; }; -template +template class period_seq { std::vector> periods_; @@ -110,10 +110,10 @@ public: [[nodiscard]] auto periods() const -> std::vector> const&; }; -template +template auto operator<<(std::ostream& os, period const& p) -> std::ostream&; -template +template auto operator<<(std::ostream& os, period_seq const& ps) -> std::ostream&; @@ -121,7 +121,7 @@ auto operator<<(std::ostream& os, period_seq const& ps) namespace routemon::time { -template +template period::period(timestamp start, timestamp end) : start_{start}, end_{end} { @@ -131,7 +131,7 @@ period::period(timestamp start, timestamp end) } } -template +template auto period::intersect(period other) const -> std::optional { auto const new_start = start_ < other.start() ? other.start() : start_; @@ -140,7 +140,7 @@ auto period::intersect(period other) const -> std::optional : std::nullopt; } -template +template auto period::except(period other) const -> std::pair, std::optional> { @@ -156,19 +156,19 @@ auto period::except(period other) const return std::make_pair(before, after); } -template +template auto period::start() const -> timestamp { return start_; } -template +template auto period::end() const -> timestamp { return end_; } -template +template period_seq::period_seq(std::vector> periods) : periods_{std::move(periods)} { @@ -185,13 +185,13 @@ period_seq::period_seq(std::vector> periods) } } -template +template period_seq::period_seq(period singleton) : periods_{singleton} { } -template +template auto period_seq::intersect(period_seq const& other) const -> period_seq { @@ -232,7 +232,7 @@ auto period_seq::intersect(period_seq const& other) const return period_seq{res}; } -template +template auto period_seq::except(period_seq const& other) const -> period_seq { // This code was pretty tricky to write, I wouldn't be surprised if it @@ -281,20 +281,20 @@ auto period_seq::except(period_seq const& other) const -> period_seq return period_seq{res}; } -template +template auto period_seq::periods() const -> std::vector> const& { return periods_; } -template +template auto operator<<(std::ostream& os, period const& p) -> std::ostream& { return os << "[" << p.start() << ", " << p.end() << ")"; } -template +template auto operator<<(std::ostream& os, period_seq const& ps) -> std::ostream& { diff --git a/server/src/util.cppm b/server/src/util.cppm index 986e350..aedc120 100644 --- a/server/src/util.cppm +++ b/server/src/util.cppm @@ -7,7 +7,7 @@ import std; namespace routemon::util { // For use with e.g. std::visit (on std::variant). -template +template struct overloaded : Ts... { using Ts::operator()...; @@ -48,7 +48,7 @@ constexpr auto parse_int(std::string_view s, int base = 10) noexcept return x; } -template +template class aolist : public std::enable_shared_from_this> { T v_; @@ -177,10 +177,10 @@ constexpr auto split_on(std::string_view s, char c) return std::make_pair(s, std::nullopt); } -template +template class not_null; -template +template class not_null { T* p_; @@ -220,7 +220,7 @@ public: auto operator->() const noexcept -> T* { return p_; } }; -template +template explicit not_null(T*) -> not_null; template <> @@ -248,7 +248,7 @@ explicit not_null(lazy_zstring_view s) -> not_null; template <> struct std::formatter { - template + template constexpr auto parse(ParseContext& ctx) -> ParseContext::iterator { auto it = ctx.begin(); @@ -259,7 +259,7 @@ struct std::formatter return it; } - template + template auto format(routemon::util::zstring_view s, FmtContext& ctx) const -> FmtContext::iterator { diff --git a/server/src/xml.cppm b/server/src/xml.cppm index 2d186da..783b192 100644 --- a/server/src/xml.cppm +++ b/server/src/xml.cppm @@ -136,10 +136,10 @@ public: }; static_assert(std::ranges::input_range); -template +template class promise; -template +template struct [[clang::coro_await_elidable, clang::coro_return_type]] parser { using promise_type = promise; @@ -204,7 +204,7 @@ using event = std::variant< processing_instructions_event, xml_decl_event, eof_event >; -template +template concept event_type = requires(event ev) { std::get(ev); }; class executor; @@ -403,7 +403,7 @@ class executor return std::exchange(ex_, nullptr); } - template + template friend class promise; public: @@ -453,7 +453,7 @@ public: auto end() -> void; }; -template +template class promise_returnable : public promise_base { std::optional returned_value_; @@ -462,7 +462,7 @@ public: using result_type = T; using promise_base::promise_base; - template + template auto return_value(U&& v) -> void { returned_value_.emplace(std::forward(v)); @@ -486,13 +486,13 @@ public: auto return_void() -> void {} }; -template +template class promise : public promise_returnable { public: // Called with all the coroutine's arguments. // Ignoring all but the first argument, which should be the executor. - template + template explicit promise(executor_ref executor, Args&&...) : promise_returnable{executor} { @@ -566,7 +566,7 @@ public: return awaiter{req.executor}; } - template + template auto await_transform(parser const& coro) { struct [[clang::coro_await_elidable]] awaiter @@ -614,10 +614,10 @@ public: // Helpers for handling XML documents. Non-polymorphic functions // should be marked inline to allow HALO across TU boundaries. -template +template concept unconstrained = true; -template concept C> +template concept C> concept parser_of = requires { typename T::result_type; requires std::same_as, T>; @@ -627,12 +627,12 @@ concept parser_of = requires { template T> using parser_result_t = T::result_type; -template +template concept parser_invocable = std::invocable && parser_of, unconstrained>; -template +template requires parser_invocable using parser_invoke_result_t = parser_result_t>; @@ -833,7 +833,7 @@ inline auto read_string_contents(executor_ref e, attribute_view) template auto hohalo() { - return []( + return []( Args&&... args) -> std::invoke_result_t { co_return co_await f(std::forward(args)...); }; } -- cgit v1.3.1