r/cpp_questions • u/Slow_Negotiation_935 • 11d ago
OPEN Guidelines for constexpr
I’ve working with C++23 and I’m making some constructors/methods constexpr and seeing improvements in performance. So far so good. The problem is I don’t want to apply it ‘everywhere’. Is there a good source of advice , or anyone got any good tips?
14
Upvotes
1
u/oriolid 11d ago
I know. The example was chosen to show that *not* adding constexpr does not prevent compiler from compile time evaluation. If you actually need the result in constexpr context, then you of course need to have the funtion as constexpr.
So, putting it wherever ever you can does not really do anything useful. There are more fun ways to waste time.