Function add [src]

Returns the sum of a and b. Returns an error on overflow.

Prototype

pub fn add(comptime T: type, a: T, b: T) (error{Overflow}!T)

Parameters

T: typea: Tb: T

Source

pub fn add(comptime T: type, a: T, b: T) (error{Overflow}!T) { if (T == comptime_int) return a + b; const ov = @addWithOverflow(a, b); if (ov[1] != 0) return error.Overflow; return ov[0]; }