Monitoring  3.3.4
O2 Monitoring library
VariantVisitorAdd.h
1 // Copyright CERN and copyright holders of ALICE O2. This software is
2 // distributed under the terms of the GNU General Public License v3 (GPL
3 // Version 3), copied verbatim in the file "COPYING".
4 //
5 // See http://alice-o2.web.cern.ch/license for full licensing information.
6 //
7 // In applying this license CERN does not waive the privileges and immunities
8 // granted to it by virtue of its status as an Intergovernmental Organization
9 // or submit itself to any jurisdiction.
10 
11 #include <variant>
12 
13 namespace o2
14 {
15 // ALICE O2 Monitoring system
16 namespace monitoring
17 {
20 {
21  public:
23  template <
24  typename T,
25  typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
26  std::variant<int, std::string, double, uint64_t> operator()(const T& a, const T& b) const
27  {
28  return a + b;
29  }
30 
33  template <typename T, typename U>
34  std::variant<int, std::string, double, uint64_t> operator()(const T&, const U&) const
35  {
36  throw MonitoringException("DerivedMetrics/Visitor", "Cannot operate on different or non-numeric types");
37  }
38 };
39 
40 } // namespace monitoring
41 } // namespace o2
Definition: Backend.h:23
std::variant< int, std::string, double, uint64_t > operator()(const T &a, const T &b) const
Overloads operator() that sums numeric values.
Definition: VariantVisitorAdd.h:26
Adds boost variants.
Definition: VariantVisitorAdd.h:19
Internal monitoring exception.
Definition: MonitoringException.h:29
std::variant< int, std::string, double, uint64_t > operator()(const T &, const U &) const
Definition: VariantVisitorAdd.h:34