| ... | @@ -8371,12 +8371,14 @@ test "integer truncation" { | ... | @@ -8371,12 +8371,14 @@ test "integer truncation" { |
| 8371 | {#header_close#} | 8371 | {#header_close#} |
| 8372 | | 8372 | |
| 8373 | {#header_open|@TypeOf#} | 8373 | {#header_open|@TypeOf#} |
| 8374 | <pre>{#syntax#}@TypeOf(expression) type{#endsyntax#}</pre> | 8374 | <pre>{#syntax#}@TypeOf(...) type{#endsyntax#}</pre> |
| 8375 | <p> | 8375 | <p> |
| 8376 | This function returns a compile-time constant, which is the type of the | 8376 | {#syntax#}@TypeOf{#endsyntax#} is a special builtin function that takes any (nonzero) number of expressions |
| 8377 | expression passed as an argument. The expression is evaluated. | 8377 | as parameters and returns the type of the result, using {#link|Peer Type Resolution#}. |
| | 8378 | </p> |
| | 8379 | <p> |
| | 8380 | The expressions are evaluated, however they are guaranteed to have no <em>runtime</em> side-effects: |
| 8378 | </p> | 8381 | </p> |
| 8379 | <p>{#syntax#}@TypeOf{#endsyntax#} guarantees no run-time side-effects within the expression:</p> | | |
| 8380 | {#code_begin|test#} | 8382 | {#code_begin|test#} |
| 8381 | const std = @import("std"); | 8383 | const std = @import("std"); |
| 8382 | const assert = std.debug.assert; | 8384 | const assert = std.debug.assert; |