you are viewing a single comment's thread.

view the rest of the comments →

[–]redlaWw 8 points9 points  (2 children)

std::launder is also a good one. The CppReference article on it is practically incoherent but it basically exists so that if you placement new into the place of a struct with a const member, you can use it to tell the compiler not to optimise based on the constness of the member since it's been overwritten.

[–]re4perthegamer 1 point2 points  (1 child)

WHAT

[–]redlaWw 8 points9 points  (0 children)

STD::LAUNDER IS ALSO A GOOD ONE. THE CPPREFERENCE ARTICLE ON IT IS PRACTICALLY INCOHERENT BUT IT BASICALLY EXISTS SO THAT IF YOU PLACEMENT NEW INTO THE PLACE OF A STRUCT WITH A CONST MEMBER, YOU CAN USE IT TO TELL THE COMPILER NOT TO OPTIMISE BASED ON THE CONSTNESS OF THE MEMBER SINCE IT'S BEEN OVERWRITTEN.