 
 extension AtomicReference
 {
+#if swift(>=4.2)
+  @inlinable
+  public mutating func swap(_ ref: T?, order: MemoryOrder = .sequential) -> T?
+  {
+    let u = Unmanaged.tryRetain(ref)?.toOpaque()
+    if let pointer = ptr.swap(u, order)
+    {
+      return Unmanaged<T>.fromOpaque(pointer).takeRetainedValue()
+    }
+    return nil
+  }
+#else
   @inline(__always)
   public mutating func swap(_ ref: T?, order: MemoryOrder = .sequential) -> T?
   {

    }
    return false
  }

  @inline(__always)
  public mutating func take(order: MemoryOrder = .sequential) -> T?
  {

    }
    return nil
  }
#endif

#if swift(>=4.2)
  @inlinable
  public mutating func swapIfNil(_ ref: T, order: MemoryOrder = .sequential) -> Bool
  {
    let u = Unmanaged.passUnretained(ref)
    if ptr.CAS(nil, u.toOpaque(), .strong, order)
    {
      _ = u.retain()
      return true
    }
    return false
  }
#else
  @inline(__always)
  public mutating func swapIfNil(_ ref: T, order: MemoryOrder = .sequential) -> Bool
  {
