Skip to content

Commit

Permalink
Merge pull request #501 from martindevans/LLamaPos_inc_dec
Browse files Browse the repository at this point in the history
Added increment and decrement operators to `LLamaPos`
  • Loading branch information
martindevans authored Feb 7, 2024
2 parents 82c471e + 90915c5 commit 859160d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions LLama/Native/LLamaPos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,24 @@ private LLamaPos(int value)
/// <param name="value"></param>
/// <returns></returns>
public static implicit operator LLamaPos(int value) => new(value);

/// <summary>
/// Increment this position
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public static LLamaPos operator ++(LLamaPos pos)
{
return new LLamaPos(pos.Value + 1);
}

/// <summary>
/// Increment this position
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public static LLamaPos operator --(LLamaPos pos)
{
return new LLamaPos(pos.Value - 1);
}
}

0 comments on commit 859160d

Please sign in to comment.