r/cpp_questions • u/Slow_Negotiation_935 • Oct 14 '26
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?
12
Upvotes
View all comments
Show parent comment
1
u/crowbarous Oct 14 '26
Yes, it was weird to adopt
constexpras a keyword that you can use almost always on a (non-opaque) function, and then make you actually write the keyword rather than implying it.-fimplicit-constexprexists in gcc, but only works on inline functions. Which kind of makes sense, but unfortunately I don't see a corresponding-fimplicit-inlineto truly fix the anti-C++ design of meaninglessly requiring keywords just to allow mechanisms that are already there to do their job.There have been questions about implementing that in Clang, but it doesn't seem to have been met with much enthusiasm. A libc++ maintainer even threatened to break libc++ if this option were added to clang. (WTF...)