@@ -19,7 +19,7 @@ extension TupleType {
1919 public init ( _ type: Any . Type ) {
2020 self . init ( rawValue: unsafeBitCast ( type, to: UnsafePointer< _Metadata> . self ) )
2121 }
22-
22+
2323 @_transparent
2424 public var isEmpty : Bool { count == 0 }
2525
@@ -36,7 +36,7 @@ extension TupleType {
3636 elementType ( at: index) . type
3737 }
3838
39- @_transparent
39+ @_transparent
4040 public func offset< T> ( at index: Int , as type: T . Type ) -> Int {
4141 elementOffset ( at: index, type: Metadata ( type) )
4242 }
@@ -46,39 +46,48 @@ extension TupleType {
4646 __OGTupleSetElement ( self , tupleValue, index, srcValue, Metadata ( T . self) , options)
4747 }
4848
49- @_transparent
49+ @_transparent
5050 public func getElement< T> ( in tupleValue: UnsafeMutableRawPointer , at index: Int , to dstValue: UnsafeMutablePointer < T > , options: CopyOptions ) {
5151 __OGTupleGetElement ( self , tupleValue, index, dstValue, Metadata ( T . self) , options)
5252 }
5353}
5454
5555@_silgen_name ( " OGTupleWithBuffer " )
56- public func withUnsafeTuple( of type: TupleType , count: Int , _ body: ( UnsafeMutableTuple ) -> ( ) )
56+ public func withUnsafeTuple( of type: TupleType , count: Int , _ body: ( UnsafeMutableTuple ) -> Void )
5757
5858// MARK: - UnsafeTuple
5959
6060extension UnsafeTuple {
61+ @_transparent
6162 public var count : Int { type. count }
63+
64+ @_transparent
6265 public var isEmpty : Bool { type. isEmpty }
66+
67+ @_transparent
6368 public var indices : Range < Int > { type. indices }
64-
69+
70+ @_transparent
6571 public func address< T> ( as _: T . Type = T . self) -> UnsafePointer < T > {
6672 guard type. type == T . self else {
6773 preconditionFailure ( )
6874 }
6975 return value. assumingMemoryBound ( to: T . self)
7076 }
71-
77+
78+ @_transparent
7279 public func address< T> ( of index: Int , as _: T . Type = T . self) -> UnsafePointer < T > {
7380 value. advanced ( by: type. elementOffset ( at: index, type: Metadata ( T . self) ) )
7481 . assumingMemoryBound ( to: T . self)
7582 }
76-
83+
7784 public subscript< T > ( ) - > T {
85+ @_transparent
7886 unsafeAddress { address ( as: T . self) }
7987 }
80-
88+
8189 public subscript< T > ( _ index: Int) - > T {
90+ @_transparent
8291 unsafeAddress { address ( of: index, as: T . self) }
8392 }
8493}
@@ -96,19 +105,19 @@ extension UnsafeMutableTuple {
96105 )
97106 )
98107 }
99-
108+
100109 @_transparent
101110 public func initialize< T> ( at index: Int , to element: T ) {
102111 withUnsafePointer ( to: element) { elementPointer in
103112 type. setElement ( in: value, at: index, from: elementPointer, options: . initCopy)
104113 }
105114 }
106-
115+
107116 @_transparent
108117 public func deinitialize( ) {
109118 type. destroy ( value)
110119 }
111-
120+
112121 @_transparent
113122 public func deinitialize( at index: Int ) {
114123 type. destroy ( value, at: index)
@@ -121,7 +130,7 @@ extension UnsafeMutableTuple {
121130 }
122131 value. deallocate ( )
123132 }
124-
133+
125134 @_transparent
126135 public var count : Int { type. count }
127136
@@ -130,30 +139,32 @@ extension UnsafeMutableTuple {
130139
131140 @_transparent
132141 public var indices : Range < Int > { type. indices }
133-
142+
134143 @_transparent
135144 public func address< T> ( as _: T . Type = T . self) -> UnsafeMutablePointer < T > {
136145 guard type. type == T . self else {
137146 preconditionFailure ( )
138147 }
139148 return value. assumingMemoryBound ( to: T . self)
140149 }
141-
150+
142151 @_transparent
143152 public func address< T> ( of index: Int , as _: T . Type = T . self) -> UnsafeMutablePointer < T > {
144153 value. advanced ( by: type. elementOffset ( at: index, type: Metadata ( T . self) ) )
145154 . assumingMemoryBound ( to: T . self)
146155 }
147-
148- @_transparent
156+
149157 public subscript< T> ( ) -> T {
158+ @_transparent
150159 unsafeAddress { UnsafePointer ( address ( as: T . self) ) }
160+ @_transparent
151161 nonmutating unsafeMutableAddress { address ( as: T . self) }
152162 }
153-
154- @_transparent
163+
155164 public subscript< T> ( _ index: Int ) -> T {
165+ @_transparent
156166 unsafeAddress { UnsafePointer ( address ( of: index, as: T . self) ) }
167+ @_transparent
157168 nonmutating unsafeMutableAddress { address ( of: index, as: T . self) }
158169 }
159170}
0 commit comments