Skip to content

Instantly share code, notes, and snippets.

@adamnemecek
Created June 17, 2016 20:38
Show Gist options
  • Save adamnemecek/c151489027bd5193d366fe56700737e8 to your computer and use it in GitHub Desktop.
Save adamnemecek/c151489027bd5193d366fe56700737e8 to your computer and use it in GitHub Desktop.
import Foundation
func copy<T: AnyObject>(obj: T) -> T {
let ptr = UnsafeMutablePointer<T>.alloc(1)
ptr.initialize(obj)
return ptr.memory
}
class C: NonObjectiveCBase {
deinit {
print("deinit")
}
}
func main() {
var c = C()
// let d = copy(c)
print(isUniquelyReferenced(&c))
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment