ATLAS Offline Software
ones.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef CXXUTILS_ONES_H
14 #define CXXUTILS_ONES_H
15 
16 
17 namespace CxxUtils {
18 
19 
23 template <class T>
24 inline
25 constexpr T ones (unsigned int n)
26 {
27  if (n >= sizeof(T) * 8)
28  return ~static_cast<T>(0);
29  // cppcheck-suppress shiftTooManyBits
30  return (static_cast<T>(1) << n) - 1;
31 }
32 
33 
34 } // namespace CxxUtils
35 
36 
37 #endif // not CXXUTILS_ONES_H
CxxUtils::ones
constexpr T ones(unsigned int n)
Return a bit mask with the lower n bits set.
Definition: ones.h:25
beamspotman.n
n
Definition: beamspotman.py:731
CxxUtils
Definition: aligned_vector.h:29