The Gaudi Framework  v32r2 (46d42edc)
Counters.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef GAUDIKERNEL_COUNTERS_H
4 # error "GaudiKernel/Counters.h cannot be included before Gaudi/Chrono/Counters.h"
5 #endif
6 
14 #include <chrono>
15 #include <cmath>
16 
17 namespace Gaudi {
18  namespace Accumulators {
19  /*
20  * std::chrono::duration only supports arithmetic operations that preserve the unit
21  * of time, e.g. there are no operations that would result in units of ms^2. This can
22  * be inconvenient for the use in general purpose libraries like Gaudi::Accumulators.
23  * This header provides the missing operators.
24  */
25 
27  template <class Rep, class Period>
29  return std::chrono::duration<Rep, Period>( static_cast<Rep>( std::round( std::sqrt( d.count() ) ) ) );
30  }
31 
33  template <class Rep1, class Rep2, class Period>
35  return std::chrono::duration<std::common_type_t<Rep1, Rep2>, Period>( lhs.count() * rhs.count() );
36  }
37  } // namespace Accumulators
38 } // namespace Gaudi
39 
40 #include "Gaudi/Chrono/ChronoIO.h"
41 #include "GaudiKernel/Counters.h"
auto operator *(const std::chrono::duration< Rep1, Period > &lhs, const std::chrono::duration< Rep2, Period > &rhs)
Multiplication of two std::chrono::duration objects with same Period.
Definition: Counters.h:34
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
Definition: Counters.h:28
T sqrt(T... args)
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
T round(T... args)