Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

alignment

Public Function
std.meta.alignment
pub fn alignment(comptime T: type) comptime_int

Returns the alignment of type T. Note that if T is a pointer type the result is different than the one returned by @alignOf(T). If T is a pointer type the alignment of the type it points to is returned.

Params

  • T: type

File

meta.zig:33
33
34
35
36
37
38
39
40
41
42
pub fn alignment(comptime T: type) comptime_int {
    return switch (@typeInfo(T)) {
        .optional => |info| switch (@typeInfo(info.child)) {
            .pointer, .@"fn" => alignment(info.child),
            else => @alignOf(T),
        },
        .pointer => |info| info.attrs.@"align" orelse @alignOf(info.child),
        else => @alignOf(T),
    };
}