On 12/08/16 12:38, Guillaume Piolat wrote:
From the best of my knowledge you cannot do these things in in C++:

https://p0nce.github.io/d-idioms/#Precomputed-tables-at-compile-time-through-CTFE

I maintain an open source program called fakeroot-ng. It is written in C++. Just today, while doing some cleanups, I ran across this point when trying to convert a table to const.

So, yes, having a CTFE to compute the table would have been great, and had fakeroot-ng been written in D, I would have. Then again, the ultimate cost of not doing this is so low, that I didn't really feel cheated out of it.

That table was not expensive to compute, and its constantness wasn't crucial enough even for me to put a wrapper pointer and only access it through it. Had that not been the case, and had that table been more expensive to computer, I'd probably compute at compile time with an external tool.

The point is that while I missed have D's CTFE to compute that table, I didn't miss it much, and I don't miss D features often. Sadly, I cannot say the same thing about the things in C++ I miss when I write D. They are both everyday and, to me, without reasonable substitutes.

Shachar

Reply via email to