Skip to content

Commit 846441f

Browse files
committed
🚨 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.
1 parent c982e97 commit 846441f

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

include/log/catalog/mipi_builder.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ template <packer P> struct builder<defn::short32_msg_t, P> {
3232

3333
template <typename Storage, packer P> struct catalog_builder {
3434
template <auto Level, packable... Ts>
35-
static auto build(string_id id, module_id m, unit_t u, Ts... args) {
35+
static auto build(string_id id, module_id m, unit_t u, Ts... args)
36+
-> defn::catalog_msg_t::owner_t<Storage> {
3637
using namespace msg;
3738
defn::catalog_msg_t::owner_t<Storage> message{
3839
"severity"_field = Level, "module_id"_field = m, "unit"_field = u};

include/lookup/pseudo_pext_lookup.hpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ constexpr auto with_mask(T const mask, std::array<T, S> const &keys)
170170
}
171171

172172
template <typename T, typename V, std::size_t S>
173-
constexpr auto get_keys(std::array<entry<T, V>, S> const &entries) {
173+
constexpr auto get_keys(std::array<entry<T, V>, S> const &entries)
174+
-> std::array<detail::raw_integral_t<T>, S> {
174175
using raw_t = detail::raw_integral_t<T>;
175176
std::array<raw_t, S> new_keys{};
176177

@@ -373,7 +374,8 @@ struct pseudo_pext_lookup {
373374
return empty_impl<key_type, value_type, default_value>{};
374375

375376
} else if constexpr (use_indirect_strategy) {
376-
constexpr auto storage = [&]() {
377+
constexpr auto storage =
378+
[&]() -> std::remove_const_t<decltype(input.entries)> {
377379
auto s = input.entries;
378380

379381
// sort by the hashed key to group all the buckets together
@@ -416,8 +418,9 @@ struct pseudo_pext_lookup {
416418
return s;
417419
}();
418420

419-
constexpr auto lookup_table = [&]() {
420-
using lookup_idx_t = detail::uint_for_<storage.size()>;
421+
using lookup_idx_t = detail::uint_for_<storage.size()>;
422+
constexpr auto lookup_table =
423+
[&]() -> std::array<lookup_idx_t, lookup_table_size> {
421424
std::array<lookup_idx_t, lookup_table_size> t{};
422425

423426
t.fill(0);
@@ -442,7 +445,9 @@ struct pseudo_pext_lookup {
442445
p, lookup_table, storage};
443446

444447
} else {
445-
constexpr auto storage = [&]() {
448+
constexpr auto storage =
449+
[&]() -> std::array<entry<raw_key_type, value_type>,
450+
lookup_table_size> {
446451
std::array<entry<raw_key_type, value_type>, lookup_table_size>
447452
s{};
448453

include/lookup/strategies.hpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@
44
#include <lookup/strategy_failed.hpp>
55

66
#include <stdx/compiler.hpp>
7+
#include <stdx/type_traits.hpp>
78

8-
namespace lookup {
9-
template <typename...> struct strategies;
9+
#include <algorithm>
10+
#include <array>
11+
#include <iterator>
1012

11-
template <> struct strategies<> {
13+
namespace lookup {
14+
struct fail_strategy_t {
1215
[[nodiscard]] CONSTEVAL static auto make(compile_time auto)
1316
-> strategy_failed_t {
1417
return {};
1518
}
1619
};
1720

18-
template <typename T, typename... Ts> struct strategies<T, Ts...> {
21+
template <typename... Ts> struct strategies {
1922
[[nodiscard]] CONSTEVAL static auto make(compile_time auto input) {
20-
constexpr auto candidate = T::make(input);
21-
22-
if constexpr (strategy_failed(candidate)) {
23-
return strategies<Ts...>::make(input);
24-
} else {
25-
return candidate;
26-
}
23+
constexpr auto idx = [&] {
24+
constexpr auto results =
25+
std::array{not strategy_failed(Ts::make(input))...};
26+
return std::distance(
27+
std::cbegin(results),
28+
std::find(std::cbegin(results), std::cend(results), true));
29+
}();
30+
return stdx::nth_t<idx, Ts..., fail_strategy_t>::make(input);
2731
}
2832
};
2933
} // namespace lookup

include/match/and.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ template <matcher L, matcher R> struct and_t : bin_op_t<and_t, "and", L, R> {
2525
auto r = simplify(m.rhs);
2626

2727
if constexpr (implies(l, r)) {
28-
return l;
28+
return [&] { return l; }();
2929
} else if constexpr (implies(r, l)) {
30-
return r;
30+
return [&] { return r; }();
3131
} else if constexpr (implies(l, negate(r)) or implies(r, negate(l))) {
3232
return never;
3333
} else {

include/match/or.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ template <matcher L, matcher R> struct or_t : bin_op_t<or_t, "or", L, R> {
2424
auto r = simplify(m.rhs);
2525

2626
if constexpr (implies(l, r)) {
27-
return r;
27+
return [&] { return r; }();
2828
} else if constexpr (implies(r, l)) {
29-
return l;
29+
return [&] { return l; }();
3030
} else if constexpr (implies(negate(l), r) or implies(negate(r), l)) {
3131
return always;
3232
} else {

0 commit comments

Comments
 (0)