Dune Core Modules (2.9.0)

counter.hh
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
14
15constexpr 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
32namespace 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
Dune namespace.
Definition: alignedallocator.hh:13
Helper class for tagging priorities.
Definition: typeutilities.hh:87
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)