3 ms·
I'm not sure what you mean that it's verbose, unnatural and ugly. To me it looks the same. In C++, you have to pass around an allocator to your templates. You
by cycloptic 6y ago
I'm not sure what you mean that it's verbose, unnatural and ugly. To me it looks the same.
In C++, you have to pass around an allocator to your templates. You can typedef this away if you want.
In Zig, you have to pass around an allocator as a function argument or a struct member. You can comptime this away if you want.
Is there some fundamental way that I missed that Zig changes this? If your actual complaint is that C++ templates are bad and you're saying Zig comptime is better, that's different than having woes about allocators.
- fsociety 6y agoThe difference is you have to pass an allocator to the standard library functions in Zig. That’s why it is idiomatic compared to C++.
- voldacar 6y agohave fun trying to globally override new and delete in C++ (hint: there is no way to do this)
- cycloptic 6y agoAre you sure? https://en.cppreference.com/w/cpp/memory/new/operator_new#Global_replacements https://en.cppreference.com/w/cpp/memory/new/operator_new#Gl... You don't need to do this if you're using allocators.