TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
count_type_occurrence.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Olivier Parcollet, Nils Wentzell
19
24
25#pragma once
26
27#include <type_traits>
28
29namespace triqs {
30
35
48 template <typename T, typename... A> struct count_type_occurrence;
49
50 // Specialization of count_type_occurrence for at least one type in the parameter pack.
51 template <typename T, typename A0, typename... A>
52 struct count_type_occurrence<T, A0, A...> : std::integral_constant<int, std::is_base_of_v<T, A0> + count_type_occurrence<T, A...>::value> {};
53
54 // Specialization of count_type_occurrence for an empty parameter pack.
55 template <typename T> struct count_type_occurrence<T> : std::integral_constant<int, 0> {};
56
67 template <typename T, typename... A> struct count_type_occurrence_not;
68
69 // Specialization of count_type_occurrence_not for at least one type in the parameter pack.
70 template <typename T, typename A0, typename... A>
71 struct count_type_occurrence_not<T, A0, A...> : std::integral_constant<int, !(std::is_base_of_v<T, A0>)+count_type_occurrence_not<T, A...>::value> {
72 };
73
74 // Specialization of count_type_occurrence_not for an empty parameter pack.
75 template <typename T> struct count_type_occurrence_not<T> : std::integral_constant<int, 0> {};
76
78
79} // namespace triqs
Number of types in a parameter pack that do not derive from (or are equal to) a given type.
Number of types in a parameter pack that derive from (or are equal to) a given type.