简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM