Zig vs D generics
German Diago
german.diago at cppmaster.net
Tue Oct 11 18:01:25 UTC 2022
On Monday, 10 October 2022 at 07:30:38 UTC, Kagamin wrote:
>>In contrast, C++ code attempting to call non-constexpr
>>functions (i.e. functions only accessible at run time) in a
>>constexpr context (i.e. functions which are available both at
>>compile time and run time) will give an error at the call site.
>
> Eh? So can C++ support an allocator that works both at compile
> time and at run time? I use such allocator in my D code so it's
> ctfeable.
Yes, it does, but it has limits
https://www.cppstories.com/2021/constexpr-new-cpp20/
As for the comment about C++ code attemping to call non-constexpr
functions. Careful with not marking functions constexpr. I used
to think it was a hell of thing. But if you think of it,
constexpr is part of the user contract. You could make a function
non-ctfe by accident in D and break user code. C++ is explicit
about it.
More information about the Digitalmars-d
mailing list