opm-common
Visitor.hpp
1 /*
2  Copyright 2023 SINTEF Digital.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
23 
24 #ifndef VISITOR_HPP
25 #define VISITOR_HPP
26 
27 #include <string>
28 #include <variant>
29 
30 namespace Opm {
31 
33 template<class... Ts>
34 struct VisitorOverloadSet : Ts...
35 {
36  using Ts::operator()...;
37 };
38 
40 template<class... Ts> VisitorOverloadSet(Ts...) -> VisitorOverloadSet<Ts...>;
41 
44 template<class Exception>
46  explicit MonoThrowHandler(const std::string& message)
47  : message_(message)
48  {}
49 
50  void operator()(std::monostate&)
51  {
52  throw Exception(message_);
53  }
54 
55  void operator()(const std::monostate&) const
56  {
57  throw Exception(message_);
58  }
59 
60 private:
61  std::string message_;
62 };
63 
64 }
65 
66 #endif
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
VisitorOverloadSet(Ts...) -> VisitorOverloadSet< Ts... >
Deduction guide for visitor overload sets.
Helper struct for for generating visitor overload sets.
Definition: Visitor.hpp:34
A functor for handling a monostate in a visitor overload set.
Definition: Visitor.hpp:45