<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Synchronization/AtomicOptionalRepresentable",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Synchronization"
    ],
    "preciseIdentifier" : "s:15Synchronization27AtomicOptionalRepresentableP"
  },
  "title" : "AtomicOptionalRepresentable"
}
-->

# AtomicOptionalRepresentable

An atomic value that also supports atomic operations when wrapped
in an `Optional`. Atomic optional representable types come with a standalone
atomic representation for their optional-wrapped variants.

```
protocol AtomicOptionalRepresentable : AtomicRepresentable
```

## Topics

### Associated Types

[`associatedtype AtomicOptionalRepresentation : BitwiseCopyable`](/documentation/Synchronization/AtomicOptionalRepresentable/AtomicOptionalRepresentation)

The storage representation type that encodes to and decodes from
`Optional<Self>` which is a suitable type when used in atomic operations
on `Optional`.

### Type Methods

[`static func decodeAtomicOptionalRepresentation(consuming Self.AtomicOptionalRepresentation) -> Self?`](/documentation/Synchronization/AtomicOptionalRepresentable/decodeAtomicOptionalRepresentation(_:))

Recovers the logical atomic type `Self?` by destroying some
`AtomicOptionalRepresentation` storage instance returned from an atomic
operation on `Optional`.

[`static func encodeAtomicOptionalRepresentation(consuming Self?) -> Self.AtomicOptionalRepresentation`](/documentation/Synchronization/AtomicOptionalRepresentable/encodeAtomicOptionalRepresentation(_:))

Destroys a value of `Self` and prepares an `AtomicOptionalRepresentation`
storage type to be used for atomic operations on `Optional`.

## Relationships

### Conforming Types

[`UnsafePointer`](/documentation/Swift/UnsafePointer)

[`UnsafeMutableRawPointer`](/documentation/Swift/UnsafeMutableRawPointer)

[`ObjectIdentifier`](/documentation/Swift/ObjectIdentifier)

[`OpaquePointer`](/documentation/Swift/OpaquePointer)

[`UnsafeRawPointer`](/documentation/Swift/UnsafeRawPointer)

[`UnsafeMutablePointer`](/documentation/Swift/UnsafeMutablePointer)

[`Unmanaged`](/documentation/Swift/Unmanaged)

### Inherits From

[`AtomicRepresentable`](/documentation/Synchronization/AtomicRepresentable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)