this compiles
this does notCode:#include <utility> #include <Windows.h> int main() { RECT rc = {0}; std::pair <LONG,LONG> ControlSize; ControlSize = std::make_pair(rc.right - rc.left,rc.bottom - rc.top); return 0; }
Code:#include <utility> #include <Windows.h> int main() { RECT rc = {0}; const std::pair <LONG,LONG> ControlSize; ControlSize = std::make_pair(rc.right - rc.left,rc.bottom - rc.top); return 0; }Notice the const. Once the ControlSize has been initialized, there is no changing it without breaking const, but you can initialize it with make_pair likeerror C2678: binary '=' : no operator found which takes a left-hand operand of type 'const std::pair<_Ty1,_Ty2>' (or there is no acceptable conversion)
Code:#include <utility> #include <Windows.h> int main() { RECT rc = {0}; const std::pair <LONG,LONG> ControlSize = std::make_pair(rc.right - rc.left,rc.bottom - rc.top); return 0; }




Reply With Quote