4 ms·
Is it? I'm mostly used to (pre-)C++11 and the only unusual operators I see are ^^T (which I presume accesses the metadata info of T) and [:e:] (which I assume s
by ginko 5mo ago
Is it? I'm mostly used to (pre-)C++11 and the only unusual operators I see are ^^T (which I presume accesses the metadata info of T) and [:e:] (which I assume somehow casts the enumerator metadata 'e' to a constant value of T).
And template for but I assume that's like inline for like in zig.
- CamouflagedKiwi 5mo agorequires is also new (not sure exactly when that appeared, it's after the last time I wrote C++ in anger) although I think it's fairly clear what it means. I can only guess at the other two. Not familiar with Zig but AFAICT `inline for` is about instructing the compiler to unroll the loop, whereas `template for` means it can be evaluated at compile time and each loop iteration can have a different type for the iteration variable. It's a bit crazy but necessary for reflection to work usefully in the way the language sets it up.
- ginko 5mo agoZig's inline for is also evaluated at comptime: https://ziglang.org/documentation/master/#inline-for https://ziglang.org/documentation/master/#inline-for
- samatman 5mo agoWell yes, but the _effect_ is to unroll the loop for runtime, if the inline-for survives that long. A for loop executed during comptime is just const stuff = comptime stuff: { for (0...8) |i| { // etc, build up some stuff } break :stuff some_stuff; }; The difference is that a comptime block won't leave behind runnable 'residue', only whatever data is constructed for later. An inline for might not leave behind an unrolled loop either, but it can.
- NooneAtAll3 5mo agorequires is concept, one of big-C-words of ++20