Quantcast
Channel: User HolyBlackCat - Stack Overflow
Viewing all articles
Browse latest Browse all 1339

Comment by HolyBlackCat on constexpr vs constexpr inline vs define - Optimizing generic utility functions in C and C++

$
0
0
constexpr functions are implicitly inline, so (2) is just a more verbose version of (1). Are you worried about just release build performance, or debug performance too? Did you compare the resulting assembly? The compiler should be able to execute the function at compile-time even without constexpr if the body is visible, so you can just make a static function in the header (which AFAIK is the only sane way to have function definitions in headers in C), and avoid any #ifdef __cplusplus hassle.

Viewing all articles
Browse latest Browse all 1339

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>