|
|
|
|
|
by jcelerier
2329 days ago
|
|
> capabilities similar to -- and at least as powerful as -- type templates, value templates, constexprs, concepts, and conditional compilation (preprocessor), with a single feature and keyword are you sure ? zig does not seem to have something that looks like concepts (an issue is open : https://github.com/ziglang/zig/issues/1268) nor a way to put restrictions on a given type passed to a function or series of function. e.g. it seems that what in C++ would be (with concepts, but the same can be written more verbosely with C++03 templates if needed) void f(IsFoobar auto x) {
}
void g(IsFoobar auto y) {
}
would require in zig to have a comptime test for the "foobar" nature of T in every function, which looks like a downgrade and does not expose the requirements cleanly in the function interface. |
|