Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is std::launder a constexpr function?

I wonder why std::launder is a constexpr function. Is there any use case where it can be used at compile time?

like image 667
Daniel Langr Avatar asked Aug 21 '18 07:08

Daniel Langr


1 Answers

Because there is absolutely no reason for it not to be. It is really just the identity function with some special additional meaning to the compiler. It cannot fail, it must not have side effects. It costs nothing to make it constexpr, and you never know when that may come in useful.

like image 102
Sebastian Redl Avatar answered Nov 19 '22 23:11

Sebastian Redl