Skip to content

Commit 005a9e6

Browse files
make amount non-recursive.
1 parent 6715802 commit 005a9e6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

amount.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
22

3+
#include<utility> // std::index_sequence
4+
#include<cstddef> // std::size_t
5+
36
namespace mlib
47
{
58
template<auto T>
@@ -14,11 +17,10 @@ namespace mlib
1417
template<auto T>
1518
constexpr auto amount<T>::times(auto&& lambda) const
1619
{
17-
lambda();
18-
if constexpr (T - 1 != 0)
20+
[] <std::size_t... indexes>(std::index_sequence<indexes...>)
1921
{
20-
amount_t<T - 1>.times(lambda);
21-
}
22+
(lambda(), void(indexes), ...);
23+
}(std::make_index_sequence<T>{});
2224
return true;
2325
}
2426
}; // namespace mlib

0 commit comments

Comments
 (0)