Show HN: C++ runtime/compile-time detection in constexpr functions
github.com
github.com
If so, that's both quite clever and something I don't think I want in my codebase :P. The good news is I'm pretty sure Daveed's proposal that you mention (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p059...) got support last time it came around EWG so I'm hoping we can just go that way.
http://saadahmad.ca/detecting-evaluation-context-inside-cons...
* `if ( __ctfe) { ... }` for compile time
* `if (!__ctfe) { ... }` for runtime
{at-both-times
{define fact
[|n| (if (= n 0)
[1]
[(* n (fact (- n 1)))])]}}
(pp {at-compile-time-expand (fact 3)})
(pp (fact 3))
https://github.com/billsix/bug"An approach for runtime dection inside a constexpr function"