From ce7ede99cfd65b00714c6f81687aea5a55bc41d5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 11 Dec 2020 16:35:03 -0800 Subject: [PATCH] ircd::m: Use universal lambda construction for query template; inline linkage. --- include/ircd/m/get.h | 6 +++--- include/ircd/m/query.h | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/ircd/m/get.h b/include/ircd/m/get.h index b83835a65..42dbd95ef 100644 --- a/include/ircd/m/get.h +++ b/include/ircd/m/get.h @@ -45,7 +45,7 @@ namespace ircd::m } template -typename std::enable_if::value, T>::type +inline typename std::enable_if::value, T>::type ircd::m::get(std::nothrow_t, const event::idx &event_idx, const string_view &key, @@ -56,7 +56,7 @@ ircd::m::get(std::nothrow_t, } template -typename std::enable_if::value, T>::type +inline typename std::enable_if::value, T>::type ircd::m::get(const event::idx &event_idx, const string_view &key) { @@ -71,7 +71,7 @@ ircd::m::get(const event::idx &event_idx, } template -typename std::enable_if::value, bool>::type +inline typename std::enable_if::value, bool>::type ircd::m::get(const event::idx &event_idx, const string_view &key, T &ret) diff --git a/include/ircd/m/query.h b/include/ircd/m/query.h index df14129f2..ff480b97c 100644 --- a/include/ircd/m/query.h +++ b/include/ircd/m/query.h @@ -13,7 +13,7 @@ namespace ircd::m { - template R query(std::nothrow_t, const event::idx &, const string_view &key, R&& def, const std::function &); + template R query(std::nothrow_t, const event::idx &, const string_view &key, R&& def, F&&); template auto query(std::nothrow_t, const event::idx &, const string_view &key, F&&); template R query(const event::idx &, const string_view &key, R&& def, F&&); @@ -26,7 +26,7 @@ namespace ircd::m /// rather than make further use of it. /// template -auto +inline auto ircd::m::query(const event::idx &event_idx, const string_view &key, F&& closure) @@ -45,7 +45,7 @@ ircd::m::query(const event::idx &event_idx, template -R +inline R ircd::m::query(const event::idx &event_idx, const string_view &key, R&& r, @@ -60,7 +60,7 @@ ircd::m::query(const event::idx &event_idx, /// return a default value. /// template -auto +inline auto ircd::m::query(std::nothrow_t, const event::idx &event_idx, const string_view &key, @@ -87,15 +87,20 @@ ircd::m::query(std::nothrow_t, /// non-throwing behavior when the event_idx/key(column) is not found by /// returning a default value supplied by the caller. /// -template -R +template +inline R ircd::m::query(std::nothrow_t, const event::idx &event_idx, const string_view &key, R&& default_, - const std::function &closure) + F&& closure) { - R ret{std::forward(default_)}; + R ret + { + std::forward(default_) + }; + m::get(std::nothrow, event_idx, key, [&ret, &closure] (const string_view &value) {