blob: e41c21604c2cfaeaf84999f06a98c7441ecbad90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef NONTYPETEMPLATE_H
#define NONTYPETEMPLATE_H
#include "libsamplemacros.h"
#include <algorithm>
#include <numeric>
template <int Size> class IntArray
{
public:
explicit IntArray(const int *data) { std::copy(data, data + Size, m_array); }
explicit IntArray(int v) { std::fill(m_array, m_array + Size, v); }
int sum() const { return std::accumulate(m_array, m_array + Size, int(0)); }
private:
int m_array[Size];
};
using IntArray2 = IntArray<2>;
using IntArray3 = IntArray<3>;
#endif // NONTYPETEMPLATE_H
|