                            order: MemoryOrder = .acqrel) -> Bool
   {
     let c = current.map(Unmanaged.passUnretained)
-    let f = future.map(Unmanaged.passUnretained)
+    let f = future.map(Unmanaged.passRetained)
 
-    guard CAtomicsCompareAndExchange(&ptr, c?.toOpaque(), f?.toOpaque(), type, order)
-      else { return false }
-    _ = f?.retain()
-    c?.release()
-    return true
+    if CAtomicsCompareAndExchange(&ptr, c?.toOpaque(), f?.toOpaque(), .strong, order)
+    {
+      c?.release()
+      return true
+    }
+
+    f?.release()
+    return false
   }
 #endif
 }

  @inlinable
  public mutating func storeIfNil(_ reference: T, order: StoreMemoryOrder = .release) -> Bool
  {
    let u = Unmanaged.passUnretained(reference)
    if CAtomicsCompareAndExchange(&ptr, nil, u.toOpaque(), .strong, MemoryOrder(rawValue: order.rawValue)!)
    {
      _ = u.retain()
      return true
    }
    return false
  }
#elseif swift(>=3.2)
  @inline(__always)
  public mutating func storeIfNil(_ reference: T, order: StoreMemoryOrder = .release) -> Bool
  {
    let u = Unmanaged.passUnretained(reference)
    if CAtomicsCompareAndExchange(&ptr, nil, u.toOpaque(), .strong, MemoryOrder(rawValue: order.rawValue)!)
    {
      _ = u.retain()
      return true
    }
    return false
  }
#else
  @inline(__always)
  public mutating func storeIfNil(_ reference: T, order: StoreMemoryOrder = .sequential) -> Bool
  {
    let u = Unmanaged.passUnretained(reference)
    if CAtomicsCompareAndExchange(&ptr, nil, u.toOpaque(), .strong, MemoryOrder(order: order))
    {
      _ = u.retain()
      return true
    }
    return false
  }
#endif

                           order: MemoryOrder = .acqrel) -> Bool
  {
    let c = current.map(Unmanaged.passUnretained)
    let f = future.map(Unmanaged.passRetained)

    if CAtomicsCompareAndExchange(&ptr, c?.toOpaque(), f?.toOpaque(), .strong, order)
    {
      c?.release()
      return true
    }

    f?.release()
    return false
  }
#else
  @inline(__always) @discardableResult
