Ocular Engine
BitOps.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_UTILITIES_BIT_OPERATIONS__H__
19 #define __H__OCULAR_UTILITIES_BIT_OPERATIONS__H__
20 
21 #include <bitset>
22 
23 //------------------------------------------------------------------------------------------
24 
29 namespace Ocular
30 {
35  namespace Utils
36  {
41  namespace BitOps
42  {
50  template<typename T>
51  bool isBitSet(T const& t, unsigned const pos)
52  {
53  bool result = false;
54  const unsigned tSize = sizeof(T) * 8;
55 
56  if(pos < tSize)
57  {
58  std::bitset<tSize> tBits(t);
59  result = static_cast<bool>(tBits[pos]);
60  }
61 
62  return result;
63  }
64  }
68  }
72 }
77 //------------------------------------------------------------------------------------------
78 
79 #endif
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70