Skip to content

Commit 0f704ef

Browse files
committed
constexpr std::array
1 parent 83d4887 commit 0f704ef

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ template <int Capacity> inplace_vector<int, Capacity> fibonacci_to(int num) {
4242

4343
inplace_vector<int, Capacity> vec;
4444

45+
constexpr static std::array<int, 2> first_two{0, 1};
4546
for (auto i = 0; i <= num; ++i) {
46-
static std::array<int, 2> first_two = {0, 1};
47-
4847
auto new_val = i < 2 ? first_two[i] : vec[i - 1] + vec[i - 2];
4948
vec.push_back(new_val);
5049
}

examples/fibonacci.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ template <int Capacity> inplace_vector<int, Capacity> fibonacci_to(int num) {
1515

1616
inplace_vector<int, Capacity> vec;
1717

18+
constexpr static std::array<int, 2> first_two{0, 1};
1819
for (auto i = 0; i <= num; ++i) {
19-
static std::array<int, 2> first_two = {0, 1};
20-
2120
auto new_val = i < 2 ? first_two[i] : vec[i - 1] + vec[i - 2];
2221
vec.push_back(new_val);
2322
}

0 commit comments

Comments
 (0)