SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
EnumArray.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 #include <array>
6 
7 namespace SDX
8 {
12  template <class TType, class TEnum>
13  class EnumArray
14  {
15  private:
16  std::array<TType, (int)TEnum::COUNT> Array;
17  public:
19  size_t size() const
20  {
21  return Array.size();
22  }
23 
25  TType& operator[](const TEnum index)
26  {
27  return Array[(int)index];
28  }
29 
31  const TType& operator[](const TEnum index) const
32  {
33  return Array[(int)index];
34  }
35 
37  auto begin() ->decltype(Array.begin())
38  {
39  return Array.begin();
40  }
41 
43  auto end() ->decltype(Array.end())
44  {
45  return Array.end();
46  }
47 
49  auto begin() const ->decltype(Array.begin())
50  {
51  return Array.begin();
52  }
53 
55  auto end() const ->decltype(Array.end())
56  {
57  return Array.end();
58  }
59  };
60 }
auto end() const -> decltype(Array.end())
範囲for用.
Definition: EnumArray.h:55
TType & operator[](const TEnum index)
[]のオペレータ.
Definition: EnumArray.h:25
auto begin() const -> decltype(Array.begin())
範囲for用.
Definition: EnumArray.h:49
const TType & operator[](const TEnum index) const
[]のオペレータ.
Definition: EnumArray.h:31
列挙型を直接添字に使える配列.
Definition: EnumArray.h:13
auto end() -> decltype(Array.end())
範囲for用.
Definition: EnumArray.h:43
size_t size() const
要素数を取得.
Definition: EnumArray.h:19
auto begin() -> decltype(Array.begin())
範囲for用.
Definition: EnumArray.h:37