I have several brief constexpr
functions in my libraries that perform some simple calculations. I use them both in run-time and compile-time contexts.
I
I believe that assert
will work for you once g++ implements N3652, Relaxing constraints on constexpr functions. Currently, this status page indicates that this has not yet been implemented.
assert
does work (in constexpr functions) on the current clang compiler shipped by Apple, with -std=c++1y
.
At this time, I see nothing in the standard that assures one that assert
will work in constexpr functions, and such an assurance would be a welcome addition to the standard (at least by me).
Update
Richard Smith drew my attention to LWG 2234 submitted by Daniel Krügler which is attempting to create the assurance I refer to above.