MyGUI: MyGUI_Bitwise.h Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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
12namespace MyGUI
13{
14
15 namespace Bitwise
16 {
19 template<typename Type>
20 static inline Type firstPO2From(Type _value)
21 {
22 --_value;
23 _value |= _value >> 16;
24 _value |= _value >> 8;
25 _value |= _value >> 4;
26 _value |= _value >> 2;
27 _value |= _value >> 1;
28 ++_value;
29 return _value;
30 }
31
33 template<typename Type>
34 static inline bool isPO2(Type _value)
35 {
36 return (_value & (_value - 1)) == 0;
37 }
38
39 };
40
41} // namespace MyGUI
42
43#endif // MYGUI_BITWISE_H_
MyGUI_Prerequest.h
MyGUI::Bitwise::isPO2
static bool isPO2(Type _value)
Definition MyGUI_Bitwise.h:34
MyGUI::Bitwise::firstPO2From
static Type firstPO2From(Type _value)
Definition MyGUI_Bitwise.h:20
MyGUI
Definition MyGUI_ActionController.h:15