dune-functions  2.5.0
flatmultiindex.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_FLATMULTIINDEX_HH
4 #define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_FLATMULTIINDEX_HH
5 
6 #include <array>
7 
8 #include <dune/common/hash.hh>
9 
10 namespace Dune {
11 namespace Functions {
12 
13 
14 
22 template<class size_type>
24  public std::array<size_type,1>
25 {
26 public:
27 
31  template<class... T>
32  constexpr FlatMultiIndex(T&&... t) :
33  std::array<size_type,1>(t...)
34  {}
35 
45  FlatMultiIndex(std::initializer_list<size_type> const &l) :
46  std::array<size_type,1>{{*l.begin()}}
47  {}
48 
49  operator const size_type& () const
50  {
51  return this->operator[](0);
52  }
53 
54  operator size_type& ()
55  {
56  return this->operator[](0);
57  }
58 
59  inline friend std::size_t hash_value(const FlatMultiIndex& arg)
60  {
61  return std::hash<size_type>()(arg);
62  }
63 
64 };
65 
66 
67 
68 } // end namespace Functions
69 } // end namespace Dune
70 
71 DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(typename size_type),DUNE_HASH_TYPE(Dune::Functions::FlatMultiIndex<size_type>))
72 
73 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_FLATMULTIINDEX_HH
FlatMultiIndex(std::initializer_list< size_type > const &l)
Construct from initializer_list.
Definition: flatmultiindex.hh:45
Definition: polynomial.hh:7
STL namespace.
A multi index class with only one level.
Definition: flatmultiindex.hh:23
constexpr FlatMultiIndex(T &&... t)
Forward constructor arguments to std::array.
Definition: flatmultiindex.hh:32