flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
which.hpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
19#ifndef WHICH_H
20#define WHICH_H
21
22#include "pp_map.hpp"
23#include <utility>
24#include <type_traits>
25
26namespace flexiblesusy {
27
28#define LAMBDA(expr) [&](){ return expr; }
29
30#define WHICH(...) lazy_which(MAP_LIST(LAMBDA, __VA_ARGS__))
31
32template<typename If, typename Then>
33auto lazy_which(If&& cif, Then&& cthen) -> decltype(cthen())
34{
35 return cif() ? cthen() : decltype(cthen()){};
36}
37
38template<typename If, typename Then, typename... Elses>
39auto lazy_which(If&& cif, Then&& cthen, Elses&&... celses)
40 -> typename std::common_type<decltype(cthen()), decltype(celses())...>::type
41{
42 return cif() ? cthen() : lazy_which(std::forward<Elses>(celses)...);
43}
44
45} // namespace flexiblesusy
46
47#endif // sum_hpp
auto lazy_which(If &&cif, Then &&cthen) -> decltype(cthen())
Definition: which.hpp:33
If[spec=!=$Failed, Pole[M[hh]]/.(HSSUSY/. spec), 0]
Definition: scan_HSSUSY.m:41