The problem that took him 5 years to fix in C++, I solved in a minute with D
Steven Schveighoffer
schveiguy at gmail.com
Thu Mar 10 02:41:51 UTC 2022
On 3/9/22 9:01 PM, matheus wrote:
> Hi,
>
> Today someone sent me this video: https://www.youtube.com/embed/ABg4_EV5L3w
> (C++ Weekly - Ep 313 - The `constexpr` Problem That Took Me 5 Years To
> Fix!).
>
> It's a 26 minute long video of a guy trying to generate a concatenated
> string during CT in C++.
>
> I was flabbergasted by the problems this poor guy had in front of him
> for a thing that shouldn't seem so complex (In my opinion of course).
> And more yet that he has being struggling with this for 5 years.
>
> So I decided to try the same with D, it was 14 lines[1] of code written
> in less than a minute and it just worked on the first try.
Watched a bunch of this video, and one thing that has stuck out to me --
the compiler is complaining about destructors.
One of the "side effects" of D having a builtin GC is that it perfectly
fits the requirements of memory allocation at compile time as well. The
heap is abstracted behind a different set of primitives, and apparently
C++ cannot figure this out because they need to worry about
destruction/free!
Am I reading this wrong?
-Steve
More information about the Digitalmars-d
mailing list