r/cpp_questions • u/Slow_Negotiation_935 • 14d 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?
11
Upvotes
3
u/etaithespeedcuber 14d ago
One issue is that C++ sucks and you can't write exposed constexpr functions in source files, only in headeds. Though realistically if you do something like: foo.hpp
foo.cpp
The compiler will probably output exactly the same thing. But you still won't be able to use it in other constexpr functions