Skip to content

Commit

Permalink
sprinkle in some constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jul 2, 2023
1 parent eb29861 commit cef8b61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion firmware/controllers/algo/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class Engine final : public TriggerStateListener {
* Slightly shorter helper function to keep the code looking clean.
*/
template<typename get_t>
auto & module() {
constexpr auto & module() {
return engineModules.get<get_t>();
}

Expand Down
18 changes: 9 additions & 9 deletions firmware/util/containers/type_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ struct type_list {
* The return type is type_list<get_t> or type_list<Mockable<get_t>>
*/
template<typename get_t>
auto get() -> std::enable_if_t<decltype(first)::template has<get_t>(),
constexpr auto get() -> std::enable_if_t<decltype(first)::template has<get_t>(),
decltype(first.template get<get_t>())> {
return first.template get<get_t>();
}

template<typename get_t>
auto get() -> std::enable_if_t<!decltype(first)::template has<get_t>(),
constexpr auto get() -> std::enable_if_t<!decltype(first)::template has<get_t>(),
decltype(others.template get<get_t>())> {
return others.template get<get_t>();
}
Expand Down Expand Up @@ -111,19 +111,19 @@ struct type_list<base_t> {
}

template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
auto & get() {
constexpr auto & get() {
return *this;
}

auto & unmock() {
constexpr auto & unmock() {
return me;
}

base_t * operator->() {
constexpr base_t * operator->() {
return &me;
}

base_t & operator*() {
constexpr base_t & operator*() {
return me;
}
};
Expand Down Expand Up @@ -170,7 +170,7 @@ struct type_list<Mockable<base_t>> {
}

template<typename get_t, typename = std::enable_if_t<has<get_t>()>>
auto & get() {
constexpr auto & get() {
return *this;
}

Expand All @@ -186,11 +186,11 @@ struct type_list<Mockable<base_t>> {
}
}

auto * operator->() {
constexpr auto * operator->() {
return cur;
}

auto & operator*() {
constexpr auto & operator*() {
return *cur;
}

Expand Down

0 comments on commit cef8b61

Please sign in to comment.