@@ -432,21 +432,29 @@ public struct ${Self}<Pointee>
432
432
}
433
433
434
434
/// Returns the next consecutive position.
435
+ ///
436
+ /// - Precondition: The result is within the bounds of the same allocation.
435
437
public func successor( ) - > ${ Self} {
436
438
return self + 1
437
439
}
438
440
439
441
/// Returns the previous consecutive position.
442
+ ///
443
+ /// - Precondition: The result is within the bounds of the same allocation.
440
444
public func predecessor( ) - > ${ Self} {
441
445
return self - 1
442
446
}
443
447
444
448
/// Returns `end - self`.
445
449
public func distance( to x: ${ Self} ) - > Int {
446
450
return x - self
451
+ ///
452
+ /// - Precondition: The result is within the bounds of the same allocation.
447
453
}
448
454
449
455
/// Returns `self + n`.
456
+ ///
457
+ /// - Precondition: The result is within the bounds of the same allocation.
450
458
public func advanced( by n: Int) - > ${ Self} {
451
459
return self + n
452
460
}
@@ -499,18 +507,22 @@ public func < <Pointee>(lhs: ${Self}<Pointee>, rhs: ${Self}<Pointee>) -> Bool {
499
507
/// - Note: The following family of operator overloads are redundant
500
508
/// with Strideable. However, optimizer improvements are needed
501
509
/// before they can be removed without affecting performance.
510
+
511
+ /// - Precondition: The result is within bounds of the same allocation.
502
512
@_transparent
503
513
public func + < Pointee> ( lhs: ${ Self} < Pointee> , rhs: Int) - > ${ Self} < Pointee> {
504
514
return ${ Self} ( Builtin . gep_Word (
505
515
lhs. _rawValue, rhs. _builtinWordValue, Pointee . self) )
506
516
}
507
517
518
+ /// - Precondition: The result is within the bounds of the same allocation.
508
519
@_transparent
509
520
public func + < Pointee> ( lhs: Int,
510
521
rhs: ${ Self} < Pointee> ) - > ${ Self} < Pointee> {
511
522
return rhs + lhs
512
523
}
513
524
525
+ /// - Precondition: The result is within the bounds of the same allocation.
514
526
@_transparent
515
527
public func - < Pointee> ( lhs: ${ Self} < Pointee> , rhs: Int) - > ${ Self} < Pointee> {
516
528
return lhs + - rhs
@@ -524,11 +536,13 @@ public func - <Pointee>(lhs: ${Self}<Pointee>, rhs: ${Self}<Pointee>) -> Int {
524
536
/ MemoryLayout< Pointee> . stride
525
537
}
526
538
539
+ /// - Precondition: The result is within the bounds of the same allocation.
527
540
@_transparent
528
541
public func += < Pointee> ( lhs: inout ${ Self} < Pointee> , rhs: Int) {
529
542
lhs = lhs + rhs
530
543
}
531
544
545
+ /// - Precondition: The result is within the bounds of the same allocation.
532
546
@_transparent
533
547
public func -= < Pointee> ( lhs: inout ${ Self} < Pointee> , rhs: Int) {
534
548
lhs = lhs - rhs
0 commit comments