LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
NumericUtils.h
Go to the documentation of this file.
1 
9 #ifndef LARCOREALG_COREUTILS_NUMERICUTILS_H
10 #define LARCOREALG_COREUTILS_NUMERICUTILS_H
11 
12 // C/C++ standard libraries
13 #include <type_traits>
14 
15 
16 namespace util {
17 
18  // @{
42  template <typename A, typename B>
43  constexpr auto absDiff(A const& a, B const& b)
44  {
45  static_assert(
46  std::is_same<std::decay_t<A>, std::decay_t<B>>(),
47  "Arguments of util::absDiff() have to be of the same type."
48  );
49  return (b > a)? (b - a): (a - b);
50  }
51  // @}
52 
53 } // namespace util
54 
55 
56 #endif // LARCOREALG_COREUTILS_NUMERICUTILS_H
57 
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:17
Int_t B
Definition: plot.C:25
constexpr auto absDiff(A const &a, B const &b)
Returns the absolute value of the difference between two values.
Definition: NumericUtils.h:43