MyGUI 3.4.3
MyGUI_Bitwise.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_BITWISE_H_
8#define MYGUI_BITWISE_H_
9
10#include "MyGUI_Prerequest.h"
11
13{
15 template<typename Type>
16 static inline Type firstPO2From(Type _value)
17 {
18 --_value;
19 _value |= _value >> 16;
20 _value |= _value >> 8;
21 _value |= _value >> 4;
22 _value |= _value >> 2;
23 _value |= _value >> 1;
24 ++_value;
25 return _value;
26 }
27
29 template<typename Type>
30 static inline bool isPO2(Type _value)
31 {
32 return (_value & (_value - 1)) == 0;
33 }
34}
35
36#endif // MYGUI_BITWISE_H_
static bool isPO2(Type _value)
static Type firstPO2From(Type _value)