Compile time function execution...
Bill Baxter
dnewsgroup at billbaxter.com
Thu Feb 15 13:31:41 PST 2007
Walter Bright wrote:
> Walter Bright wrote:
>> This should obsolete using templates to compute values at compile time.
>
> For contrast, compare with the C++ proposal:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1972.pdf
It's kinda long and boring, but it looks like the key differences are
1) The need to tag compile-time functions with a new keyword,
"constexpr", though they seem to sell this as an advantage. "a
programmer can state that a function is intended to be used in a
constant expression and the compiler can diagnose mistakes." -- page 9.
2) The restriction that a constexpr function can only contain "return"
followed by exactly one expression. No loops for you! And I hope you
like quadruply nested b?x:y expressions!
That's just a proposal, though, right? Has it been accepted for C++09?
Seems like a hard sell given the limitations and the new keyword.
--bb
More information about the Digitalmars-d
mailing list