Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Template float/int comparison
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #include <Windows.h> template<typename T> static int ConvertBorderColor( const T (&borderColor)[4]) { int ret = -1; if ((borderColor[0] == 1) && (borderColor[1] == 1) && (borderColor[2] == 1) && (borderColor[3] == 1)) { ret = 0; } else if ((borderColor[0] == 0) && (borderColor[1] == 0) && (borderColor[2] == 0) && (borderColor[3] == 0)) { ret = 1; } else if ((borderColor[0] == 0) && (borderColor[1] == 0) && (borderColor[2] == 0) && (borderColor[3] == 1)) { ret = 2; } return ret; } int main() { const FLOAT borderColorF[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; std::cout << ConvertBorderColor(borderColorF) << std::endl; const UINT borderColorU[4] = { 0, 0, 0, 1 }; std::cout << ConvertBorderColor(borderColorU) << std::endl; }
run
|
edit
|
history
|
help
0
Compile time creation of class member stl container (const std::array) filled with elements.
c++ pure apstraction
vaska
Workaround for https://github.com/Project-OSRM/osrm-backend/pull/4385
div64 inline asm
Test
const_pointer_cast
hangman
RVO hota hai bhenchod
#32