dune-functions  2.7.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 
30 template<class size_type>
32  public std::array<size_type,1>
33 {
34 public:
35 
36  constexpr FlatMultiIndex() = default;
37 
47  FlatMultiIndex(std::initializer_list<size_type> const &l) :
48  std::array<size_type,1>{{*l.begin()}}
49  {}
50 
56  operator const size_type& () const
57  {
58  return this->operator[](0);
59  }
60 
66  operator size_type& ()
67  {
68  return this->operator[](0);
69  }
70 
76  inline friend std::size_t hash_value(const FlatMultiIndex& arg) noexcept
77  {
78  return std::hash<size_type>()(arg);
79  }
80 
81  static constexpr std::size_t max_size() { return 1; }
82 };
83 
84 
85 
86 } // end namespace Functions
87 } // end namespace Dune
88 
89 DUNE_DEFINE_HASH(DUNE_HASH_TEMPLATE_ARGS(typename size_type),DUNE_HASH_TYPE(Dune::Functions::FlatMultiIndex<size_type>))
90 
91 #endif // DUNE_FUNCTIONS_FUNCTIONSPACEBASES_FLATMULTIINDEX_HH
Dune::Functions::FlatMultiIndex::FlatMultiIndex
FlatMultiIndex(std::initializer_list< size_type > const &l)
Construct from initializer_list.
Definition: flatmultiindex.hh:47
Dune::Functions::FlatMultiIndex
A multi-index class with only one level.
Definition: flatmultiindex.hh:31
Dune::Functions::FlatMultiIndex::max_size
static constexpr std::size_t max_size()
Definition: flatmultiindex.hh:81
Dune::Functions::FlatMultiIndex::FlatMultiIndex
constexpr FlatMultiIndex()=default
Dune
Definition: polynomial.hh:10
Dune::Functions::FlatMultiIndex::hash_value
friend std::size_t hash_value(const FlatMultiIndex &arg) noexcept
Compute hash value for FlatMultiIndex.
Definition: flatmultiindex.hh:76