From 846441f210dc12fa38bc7dbb87558e6a54b71a89 Mon Sep 17 00:00:00 2001 From: Ben Deane Date: Fri, 26 Sep 2025 22:04:11 -0600 Subject: [PATCH] :rotating_light: Fix warnings arising from `-Wnrvo` Problem: - CIB is not warning free with respect to -Wnrvo. Solution: - Add some trailing return types etc to fix warnings. --- include/log/catalog/mipi_builder.hpp | 3 ++- include/lookup/pseudo_pext_lookup.hpp | 15 ++++++++++----- include/lookup/strategies.hpp | 26 +++++++++++++++----------- include/match/and.hpp | 4 ++-- include/match/or.hpp | 4 ++-- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/include/log/catalog/mipi_builder.hpp b/include/log/catalog/mipi_builder.hpp index bacbea00..da88ffe0 100644 --- a/include/log/catalog/mipi_builder.hpp +++ b/include/log/catalog/mipi_builder.hpp @@ -32,7 +32,8 @@ template struct builder { template struct catalog_builder { template - static auto build(string_id id, module_id m, unit_t u, Ts... args) { + static auto build(string_id id, module_id m, unit_t u, Ts... args) + -> defn::catalog_msg_t::owner_t { using namespace msg; defn::catalog_msg_t::owner_t message{ "severity"_field = Level, "module_id"_field = m, "unit"_field = u}; diff --git a/include/lookup/pseudo_pext_lookup.hpp b/include/lookup/pseudo_pext_lookup.hpp index a660eb6f..5af448b8 100644 --- a/include/lookup/pseudo_pext_lookup.hpp +++ b/include/lookup/pseudo_pext_lookup.hpp @@ -170,7 +170,8 @@ constexpr auto with_mask(T const mask, std::array const &keys) } template -constexpr auto get_keys(std::array, S> const &entries) { +constexpr auto get_keys(std::array, S> const &entries) + -> std::array, S> { using raw_t = detail::raw_integral_t; std::array new_keys{}; @@ -373,7 +374,8 @@ struct pseudo_pext_lookup { return empty_impl{}; } else if constexpr (use_indirect_strategy) { - constexpr auto storage = [&]() { + constexpr auto storage = + [&]() -> std::remove_const_t { auto s = input.entries; // sort by the hashed key to group all the buckets together @@ -416,8 +418,9 @@ struct pseudo_pext_lookup { return s; }(); - constexpr auto lookup_table = [&]() { - using lookup_idx_t = detail::uint_for_; + using lookup_idx_t = detail::uint_for_; + constexpr auto lookup_table = + [&]() -> std::array { std::array t{}; t.fill(0); @@ -442,7 +445,9 @@ struct pseudo_pext_lookup { p, lookup_table, storage}; } else { - constexpr auto storage = [&]() { + constexpr auto storage = + [&]() -> std::array, + lookup_table_size> { std::array, lookup_table_size> s{}; diff --git a/include/lookup/strategies.hpp b/include/lookup/strategies.hpp index b4b42b5c..34410dbb 100644 --- a/include/lookup/strategies.hpp +++ b/include/lookup/strategies.hpp @@ -4,26 +4,30 @@ #include #include +#include -namespace lookup { -template struct strategies; +#include +#include +#include -template <> struct strategies<> { +namespace lookup { +struct fail_strategy_t { [[nodiscard]] CONSTEVAL static auto make(compile_time auto) -> strategy_failed_t { return {}; } }; -template struct strategies { +template struct strategies { [[nodiscard]] CONSTEVAL static auto make(compile_time auto input) { - constexpr auto candidate = T::make(input); - - if constexpr (strategy_failed(candidate)) { - return strategies::make(input); - } else { - return candidate; - } + constexpr auto idx = [&] { + constexpr auto results = + std::array{not strategy_failed(Ts::make(input))...}; + return std::distance( + std::cbegin(results), + std::find(std::cbegin(results), std::cend(results), true)); + }(); + return stdx::nth_t::make(input); } }; } // namespace lookup diff --git a/include/match/and.hpp b/include/match/and.hpp index c0ac55ab..739ebf26 100644 --- a/include/match/and.hpp +++ b/include/match/and.hpp @@ -25,9 +25,9 @@ template struct and_t : bin_op_t { auto r = simplify(m.rhs); if constexpr (implies(l, r)) { - return l; + return [&] { return l; }(); } else if constexpr (implies(r, l)) { - return r; + return [&] { return r; }(); } else if constexpr (implies(l, negate(r)) or implies(r, negate(l))) { return never; } else { diff --git a/include/match/or.hpp b/include/match/or.hpp index eb86413f..9ab54ed4 100644 --- a/include/match/or.hpp +++ b/include/match/or.hpp @@ -24,9 +24,9 @@ template struct or_t : bin_op_t { auto r = simplify(m.rhs); if constexpr (implies(l, r)) { - return r; + return [&] { return r; }(); } else if constexpr (implies(r, l)) { - return l; + return [&] { return l; }(); } else if constexpr (implies(negate(l), r) or implies(negate(r), l)) { return always; } else {