diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-07 06:42:36 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-07 06:42:36 +0100 |
commit | 2cf1d750c2e834596c0556a16ea2e4b3fdd7003f (patch) | |
tree | 59718327938b1462031a6d38b6cb9949608cb7a7 /opentrack/simple-mat.hpp | |
parent | 8e9314e97a9433be35906dd9f3227c078d5f8f60 (diff) |
simple-mat inits without a temp array now
Diffstat (limited to 'opentrack/simple-mat.hpp')
-rw-r--r-- | opentrack/simple-mat.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 8e39a14f..b36b21ba 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -1,4 +1,5 @@ #pragma once +#include <initializer_list> template<typename num, int h, int w> struct Mat @@ -26,6 +27,14 @@ struct Mat num operator()(int j, int i) const { return data[j][i]; } num& operator()(int j, int i) { return data[j][i]; } + Mat(std::initializer_list<num>&& list) + { + auto iter = list.begin(); + for (int i = 0; i < h; i++) + for (int j = 0; j < w; j++) + data[i][j] = *iter++; + } + Mat() { for (int j = 0; j < h; j++) |