Skip to content

Instantly share code, notes, and snippets.

View CaramelHeaven's full-sized avatar

未来からの猫 CaramelHeaven

View GitHub Profile
@nyg
nyg / MemoryAddress.swift
Last active July 9, 2024 03:38
Get the memory address of both class and structure instances in Swift.
// https://stackoverflow.com/a/45777692/5536516
import Foundation
struct MemoryAddress<T>: CustomStringConvertible {
let intValue: Int
var description: String {
let length = 2 + 2 * MemoryLayout<UnsafeRawPointer>.size