dune-istl  2.9.0
counter.hh
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 #ifndef DUNE_ISTL_COMMON_COUNTER_HH
4 #define DUNE_ISTL_COMMON_COUNTER_HH
5 
6 #include <cassert>
7 #include <typeinfo>
8 #include <iostream>
9 #include <memory>
10 #include <tuple>
11 #include <utility>
12 
13 #include <dune/common/typeutilities.hh>
14 
15 constexpr std::size_t maxcount = 100;
16 
17 #define DUNE_GET_COUNTER(Tag) \
18  (counterFunc(Dune::PriorityTag<maxcount>{}, Tag{}, Dune::CounterImpl::ADLTag{}))
19 
20 #define DUNE_INC_COUNTER(Tag) \
21  namespace { \
22  namespace CounterImpl { \
23  constexpr std::size_t \
24  counterFunc(Dune::PriorityTag<DUNE_GET_COUNTER(Tag)+1> p, Tag, ADLTag) \
25  { \
26  return p.value; \
27  } \
28  } \
29  } \
30  static_assert(true, "unfudge indentation")
31 
32 namespace Dune {
33  namespace {
34 
35  namespace CounterImpl {
36 
37  struct ADLTag {};
38 
39  template<class Tag>
40  constexpr std::size_t counterFunc(Dune::PriorityTag<0>, Tag, ADLTag)
41  {
42  return 0;
43  }
44 
45  } // end namespace CounterImpl
46  } // end empty namespace
47 } // end namespace Dune
48 #endif // DUNE_ISTL_COMMON_COUNTER_HH
constexpr std::size_t maxcount
Definition: counter.hh:15
Definition: allocator.hh:11