| ... | @@ -9239,10 +9239,10 @@ test "vector @shuffle" { | ... | @@ -9239,10 +9239,10 @@ test "vector @shuffle" { |
| 9239 | {#header_close#} | 9239 | {#header_close#} |
| 9240 | | 9240 | |
| 9241 | {#header_open|@splat#} | 9241 | {#header_open|@splat#} |
| 9242 | <pre>{#syntax#}@splat(comptime len: u32, scalar: anytype) @Vector(len, @TypeOf(scalar)){#endsyntax#}</pre> | 9242 | <pre>{#syntax#}@splat(scalar: anytype) anytype{#endsyntax#}</pre> |
| 9243 | <p> | 9243 | <p> |
| 9244 | Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value | 9244 | Produces a vector where each element is the value {#syntax#}scalar{#endsyntax#}. |
| 9245 | {#syntax#}scalar{#endsyntax#}: | 9245 | The return type and thus the length of the vector is inferred. |
| 9246 | </p> | 9246 | </p> |
| 9247 | {#code_begin|test|test_splat_builtin#} | 9247 | {#code_begin|test|test_splat_builtin#} |
| 9248 | const std = @import("std"); | 9248 | const std = @import("std"); |
| ... | @@ -9250,8 +9250,7 @@ const expect = std.testing.expect; | ... | @@ -9250,8 +9250,7 @@ const expect = std.testing.expect; |
| 9250 | | 9250 | |
| 9251 | test "vector @splat" { | 9251 | test "vector @splat" { |
| 9252 | const scalar: u32 = 5; | 9252 | const scalar: u32 = 5; |
| 9253 | const result = @splat(4, scalar); | 9253 | const result: @Vector(4, u32) = @splat(scalar); |
| 9254 | try comptime expect(@TypeOf(result) == @Vector(4, u32)); | | |
| 9255 | try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 })); | 9254 | try expect(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 })); |
| 9256 | } | 9255 | } |
| 9257 | {#code_end#} | 9256 | {#code_end#} |
| ... | @@ -9292,8 +9291,9 @@ const std = @import("std"); | ... | @@ -9292,8 +9291,9 @@ const std = @import("std"); |
| 9292 | const expect = std.testing.expect; | 9291 | const expect = std.testing.expect; |
| 9293 | | 9292 | |
| 9294 | test "vector @reduce" { | 9293 | test "vector @reduce" { |
| 9295 | const value = @Vector(4, i32){ 1, -1, 1, -1 }; | 9294 | const V = @Vector(4, i32); |
| 9296 | const result = value > @splat(4, @as(i32, 0)); | 9295 | const value = V{ 1, -1, 1, -1 }; |
| | 9296 | const result = value > @as(V, @splat(0)); |
| 9297 | // result is { true, false, true, false }; | 9297 | // result is { true, false, true, false }; |
| 9298 | try comptime expect(@TypeOf(result) == @Vector(4, bool)); | 9298 | try comptime expect(@TypeOf(result) == @Vector(4, bool)); |
| 9299 | const is_all_true = @reduce(.And, result); | 9299 | const is_all_true = @reduce(.And, result); |