         return result
     }
     
+    @_transparent
     @discardableResult
     private mutating func _fetchStore(_ new: AtomicBase<Instance>) -> AtomicBase<Instance> {
         let _new = Unmanaged.passRetained(new)
-        @_transparent
-        func exchange(theVal: UnsafeMutablePointer<AtomicBase<Instance>>) -> UnsafeMutableRawPointer {
-            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(_new.toOpaque(), $0) }
-        }
-        let _old = Unmanaged<AtomicBase<Instance>>.fromOpaque(UnsafeRawPointer(exchange(theVal: &base)))
+        let result = withUnsafeMutablePointer(to: &base) { $0.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(_new.toOpaque(), $0) } }
+        let _old = Unmanaged<AtomicBase<Instance>>.fromOpaque(UnsafeRawPointer(result!))
         return _old.takeRetainedValue()
     }
 }

    
    @_inlineable
    public mutating func isLockFree() -> Bool {
        @_transparent
        func _isLockFree(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> Bool {
            return theVal.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicPtrIsLockFree($0) }
        }
        return _isLockFree(&self)
    }
    
    /// Atomic fetch the current value with barrier.
    @_inlineable
    public mutating func fetchSelf() -> (current: OpaquePointer, value: OpaquePointer) {
        @_transparent
        func load(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> UnsafeMutableRawPointer {
            return theVal.withMemoryRebound(to: Optional<UnsafeRawPointer>.self, capacity: 1) { _AtomicLoadPtrBarrier($0) }
        }
        let val = OpaquePointer(load(&self))
        return (val, val)
    }
    
    /// Atomic sets the value with barrier.
    @_inlineable
    public mutating func store(_ new: OpaquePointer) {
        @_transparent
        func store(_ theVal: UnsafeMutablePointer<OpaquePointer>) {
            theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicStorePtrBarrier(UnsafeMutableRawPointer(new), $0) }
        }
        store(&self)
    }
    
    /// Compare and set pointers with barrier.
    @_inlineable
    public mutating func compareSet(old: OpaquePointer, new: OpaquePointer) -> Bool {
        @_transparent
        func cas(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> Bool {
            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicCompareAndSwapPtrBarrier(UnsafeMutableRawPointer(old), UnsafeMutableRawPointer(new), $0) }
        }
        return cas(&self)
    }
    
    /// Set pointers with barrier.
    @_inlineable
    public mutating func fetchStore(_ new: OpaquePointer) -> OpaquePointer {
        @_transparent
        func exchange(_ theVal: UnsafeMutablePointer<OpaquePointer>) -> UnsafeMutableRawPointer {
            return theVal.withMemoryRebound(to: Optional<UnsafeMutableRawPointer>.self, capacity: 1) { _AtomicExchangePtrBarrier(UnsafeMutableRawPointer(new), $0) }
        }
        return OpaquePointer(exchange(&self))
    }
}


    
    private var base: AtomicBase<Instance>
    
    @_transparent
    private init(base: AtomicBase<Instance>) {
        self.base = base
    }
