Czy mogę w jakiś zmyślny, binarny lub arytmetyczny sposób zamienić flagi?
#include <iostream>
using namespace std;
enum struct WindowFlags : uint32_t{
Shown = 1 << 0,
FullScreen = 1 << 1,
BorderLess = 1 << 2
};
inline WindowFlags operator|(WindowFlags a, WindowFlags b)
{return static_cast<WindowFlags>(static_cast<int>(a) | static_cast<int>(b));}
enum struct Linux_WindowFlags : uint32_t{
FullScreen = 1 << 0,
BorderLess = 1 << 1,
Shown = 1 << 3
};
uint32_t Linux_processWindowFlags(WindowFlags flags){
uint32_t result = (uint32_t)flags;
//TODO
return result;
}
int main() {
WindowFlags windowFlags = WindowFlags::Shown | WindowFlags::BorderLess;
uint32_t linux_windowFlags = (uint32_t)Linux_processWindowFlags(windowFlags);
if((uint32_t)linux_windowFlags & (uint32_t)Linux_WindowFlags::Shown) cout << "dobre!";
return 0;
}
Inny przykład:
1)
xxxx
abcd
2)
xxxx
bcda
1) 1001 == 2) 0011